Skip to content

[probes.browser] Make testspec matching less sensitive to testDir path. - #1085

Merged
manugarg merged 6 commits into
mainfrom
browser_test_spec_fix
May 28, 2025
Merged

manugarg merged 6 commits into
mainfrom
browser_test_spec_fix

Conversation

@manugarg

@manugarg manugarg commented May 28, 2025 •

Copy link
Copy Markdown
Contributor

In some cases testDir may have symlinks to the test spec. This happens for example for k8s config maps. If you mount a config map, say at /cfg, containing a test spec say test.spec.ts, its path on the filesystem will look like the following:

ls -l /cfg

test.spec.ts -> ..data/test.spec.ts

In such cases, playwright will evaluate file path as /cfg/..data/test.spec.ts (note ..data itself will be a symlink so final path will be even longer). In that case, if we specify test spec as ^/cfg/test.spec.ts$ it will not match anything.

To workaround this problem, let's leave out testDir from the test spec regex. We'll use `^.*/test.spec.ts$ instead.

For posterity:
Playwright code for file matching:
https://github.com/microsoft/playwright/blob/eb5e3b37402bad85e6c2b976e1a596cca0e4f47c/packages/playwright/src/util.ts#L96
for collecting file:
https://github.com/microsoft/playwright/blob/eb5e3b37402bad85e6c2b976e1a596cca0e4f47c/packages/playwright/src/runner/projectUtils.ts#L169

@manugarg
manugarg merged commit b3f8402 into main May 28, 2025
@manugarg
manugarg deleted the browser_test_spec_fix branch May 28, 2025 21:31
@manugarg

Copy link
Copy Markdown
Contributor Author

Since it caused so much pain (and all AI chatbots kept saying playwright doesn't resolve symlinks (partially true), though grok was more helpful), I dug further and found the root cause:

It is the isFile() that fails on symlinks.

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