Skip to content

fix: Fix for Playwright instrumentation failing from compiled tests - #2932

Closed
declancarrollcb wants to merge 1 commit into
DataDog:masterfrom
declancarrollcb:playwright-instrumentation-compiled-fix
Closed

fix: Fix for Playwright instrumentation failing from compiled tests#2932
declancarrollcb wants to merge 1 commit into
DataDog:masterfrom
declancarrollcb:playwright-instrumentation-compiled-fix

Conversation

@declancarrollcb

Copy link
Copy Markdown

What does this PR do?

This PR fixes an issue where the Datadog Playwright instrumentation throws an unhandled exception when running compiled Playwright tests from another directory. It updates the test file path handling to ensure that the correct file paths are used during instrumentation.

Motivation

The motivation behind this PR is to resolve the issue mentioned in #2924, allowing users to run compiled Playwright tests from another directory without encountering errors.

@codecov

codecov Bot commented Mar 24, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2932 (9a44b0e) into master (5d3a123) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #2932   +/-   ##
=======================================
  Coverage   87.59%   87.59%           
=======================================
  Files         324      324           
  Lines       11573    11573           
  Branches       33       33           
=======================================
  Hits        10137    10137           
  Misses       1436     1436           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@juan-fernandez

Copy link
Copy Markdown
Collaborator

hey @declancarrollcb ! Thanks for the contribution!

I'm still struggling to have a reproducible case: do you only see the error when using Windows? The code looks reasonable but I can't properly evaluate it without testing it.

@declancarrollcb

Copy link
Copy Markdown
Author

Hey Juan,

It happens both when we are running it on Linux, and when I run it locally on Windows. I've a small repo here where it's reproduced: https://github.com/declancarrollcb/playwright-datadog-trace-issue

@juan-fernandez

juan-fernandez commented Mar 24, 2023

Copy link
Copy Markdown
Collaborator

Hey Juan,

It happens both when we are running it on Linux, and when I run it locally on Windows. I've a small repo here where it's reproduced: https://github.com/declancarrollcb/playwright-datadog-trace-issue

thank you very much! That was really helpful. So I think the issue can be more easily fixed by using the correct test attribute. I was using test._requireFile when defining the dictionary but test.location.file when accessing it. This is usually fine, but not always. I tested the fix in your repo and tests now seem to be reported correctly: declancarrollcb/playwright-datadog-trace-issue#1

The fix is in this PR: #2935

Could you test it too? 😄 You can install the branch with:

npm install --save-dev https://github.com/DataDog/dd-trace-js/tarball/juan-fernandez/fix-playwright-require-issue

@declancarrollcb

Copy link
Copy Markdown
Author

That looks good to me, I've run it and it's all passing fine. That's also a far cleaner solution than I had 😄

@juan-fernandez

Copy link
Copy Markdown
Collaborator

hey @declancarrollcb thanks for the contribution 😄 . The linked issue should be fixed in #2935. I'm closing this PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants