Skip to content

Conversation

@thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Feb 11, 2026

Motivation

E2E test output always showed the same file location for every test, regardless of which scenario file defined it:

[435/711] [Firefox] β€Ί test/e2e/lib/framework/createTest.ts:228:3 β€Ί rum views β€Ί send performance timings along the view events
[436/711] [Firefox] β€Ί test/e2e/lib/framework/createTest.ts:228:3 β€Ί rum views β€Ί loading time β€Ί has a loading time
[437/711] [Firefox] β€Ί test/e2e/lib/framework/createTest.ts:228:3 β€Ί rum views β€Ί loading time β€Ί does not have a loading time when DOM mutations are notified continuously

This happened because Playwright determines test location from the call stack when test() is called, and all tests were registered via declareTest() in createTest.ts.

Changes

Capture the caller location when createTest() is called in a scenario file, then pass it to Playwright's internal TestTypeImpl._createTest() which accepts a custom location β€” bypassing the automatic stack-trace-based detection.

[1/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:5:13 β€Ί rum views β€Ί send performance timings along the view events
[2/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:53:15 β€Ί rum views β€Ί loading time β€Ί excludes some dom mutation when computing the loading time
[3/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:71:13 β€Ί rum views β€Ί send performance first input delay
[4/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:34:15 β€Ί rum views β€Ί loading time β€Ί has a loading time
[5/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:43:15 β€Ί rum views β€Ί loading time β€Ί does not have a loading time when DOM mutations are notified continuously
[6/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:88:15 β€Ί rum views β€Ί anchor navigation β€Ί don't create a new view when it is an Anchor navigation
[7/7] [chromium] β€Ί test/e2e/scenario/rum/views.scenario.ts:105:15 β€Ί rum views β€Ί anchor navigation β€Ί create a new view on hash change

Note

This relies on Playwright's internal TestTypeImpl accessed via Symbol("testType") on the test function. This pattern has been stable since at least Playwright v1.34 and is also used by gherkin-wrapper. A fallback to the standard test() API is included if the internal API is unavailable.

Test plan

  • yarn test:e2e -g "rum views" β€” 7 passed, locations point to scenario file
  • yarn test:e2e -g "init" β€” 37 passed, locations point to scenario files

@thomas-lebeau thomas-lebeau requested a review from a team as a code owner February 11, 2026 20:34
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 11, 2026

βœ…Β Tests

πŸŽ‰ All green!

❄️ No new flaky tests detected
πŸ§ͺ All tests passed

🎯 Code Coverage
β€’ Patch Coverage: 100.00%
β€’ Overall Coverage: 77.25% (-0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
πŸ”— Commit SHA: 018e1d0 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

Playwright reports test locations based on where `test()` is called.
Since all tests were registered via `declareTest()` in `createTest.ts`,
every test showed the same `createTest.ts:228:3` location regardless
of which scenario file defined it.

Fix by capturing the caller location when `createTest()` is called and
passing it to Playwright's internal `TestTypeImpl._createTest()` which
accepts a custom location, bypassing the automatic stack-trace-based
detection.
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/fix-e2e-test-locations branch from b8257a8 to 018e1d0 Compare February 11, 2026 21:16
@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 11, 2026

Bundles Sizes Evolution

πŸ“¦ Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.43 KiB 169.43 KiB 0 B 0.00% βœ…
Rum Profiler 4.29 KiB 4.29 KiB 0 B 0.00% βœ…
Rum Recorder 24.54 KiB 24.54 KiB 0 B 0.00% βœ…
Logs 56.72 KiB 56.72 KiB 0 B 0.00% βœ…
Flagging 944 B 944 B 0 B 0.00% βœ…
Rum Slim 126.26 KiB 126.26 KiB 0 B 0.00% βœ…
Worker 23.63 KiB 23.63 KiB 0 B 0.00% βœ…
πŸš€ CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0049 0.0063 +28.57%
RUM - add action 0.0164 0.0231 +40.85%
RUM - add error 0.0155 0.0239 +54.19%
RUM - add timing 0.0032 0.0044 +37.50%
RUM - start view 0.0165 0.0244 +47.88%
RUM - start/stop session replay recording 0.0009 0.0014 +55.56%
Logs - log message 0.023 0.0324 +40.87%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add action 50.58 KiB 50.21 KiB -372 B
RUM - add global context 27.77 KiB 27.07 KiB -715 B
RUM - add timing 26.51 KiB 27.05 KiB +543 B
RUM - add error 56.46 KiB 55.16 KiB -1.31 KiB
RUM - start/stop session replay recording 26.01 KiB 26.48 KiB +481 B
RUM - start view 454.96 KiB 454.89 KiB -69 B
Logs - log message 45.95 KiB 46.31 KiB +369 B

πŸ”— RealWorld

@thomas-lebeau thomas-lebeau changed the title βœ… Show actual scenario file locations in E2E test output πŸ‘· Show actual scenario file locations in E2E test output Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant