-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Allow specifying custom export conditions in playwright test config #33684
Comments
@mrginglymus Playwright defers to Node.js to resolve export conditions from the |
Sure! Whilst I can see that playwright is deferring to nodes resolution, there is no way to configure that like there is in vite, jest, webpack, typescript, esbuild and so on. I've raised this issue in part because the two standard workarounds don't work - setting The custom hook, at simplest, looks like this:
and was imported in
What did work was patching this line:
to be const result = await defaultResolve(specifier, {...context, conditions: ['<condition>', ...context.conditions]}, defaultResolve); So my ideal API would be an option somewhere on the playwright test config that allows me to specify a list of additional conditions which are used in any import resolution - or, it could even sniff them from the vite config, to save having to specify them twice. |
@mrginglymus Thanks for the explanation! Looking at our code, I think that passing In fact, when I run with "exports": {
"development": "./dev.js",
"default": "./def.js"
}, I wonder how is my setup different from yours. Could you please share a sample repro that does not work? |
I suspect the answer is "yarn pnp", but I'll try and put together a repro tomorrow - thanks. |
The https://github.com/mrginglymus/pw-eg Here's a repro - If you switch the The fun part is that if I set However! I wouldn't focus too much on why |
@mrginglymus Thank you! It seems like there is some issue with yarn pnp and passing Playwright registers its own hook, as you've noticed, so when you are registering a second one from the config, we probably trigger nodejs/node#50948. I was able to reproduce this in my setup as well. I guess we'll have to wait for the node issue to be fixed. Now that we've checked all the options, I'll leave this issue up for prioritization. For now, I'd recommend to make the |
Ah, nice find, that looks like it indeed. Thanks for all the help. |
🚀 Feature Request
Add option to specifiy additional custom export conditions, analagous to jest's
customExportConditions
Example
No response
Motivation
I currently use custom export specifiers to allow switching between raw and compiled sources within my library. This allows for speedy development against local sources with verification that the build process hasn't broken anything, without having to do import mapping in every different bit of tooling.
Currently, playwright does not appear support custom conditions for its test files in the experimental component testing libraries.
Whilst code under test can have this done, by setting:
ie, the vite config, no such equivalent exists for the test files themselves.
I have tried launching playwright test with the
NODE_OPTIONS
env var set to-C <my_condition>
; this however prevents yarn from resolving the playwright cli entrypoint:The text was updated successfully, but these errors were encountered: