π· Show actual scenario file locations in E2E test output #4166
+62
β5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
E2E test output always showed the same file location for every test, regardless of which scenario file defined it:
This happened because Playwright determines test location from the call stack when
test()is called, and all tests were registered viadeclareTest()increateTest.ts.Changes
Capture the caller location when
createTest()is called in a scenario file, then pass it to Playwright's internalTestTypeImpl._createTest()which accepts a custom location β bypassing the automatic stack-trace-based detection.Note
This relies on Playwright's internal
TestTypeImplaccessed viaSymbol("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 standardtest()API is included if the internal API is unavailable.Test plan
yarn test:e2e -g "rum views"β 7 passed, locations point to scenario fileyarn test:e2e -g "init"β 37 passed, locations point to scenario files