-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[TestRunner] tsconfig, babel, tsx, esm metabug #7121
Comments
Is this a regression that may be temporarily worked around with an older version? |
This is a meta issue where we collect feedback to make @playwright/test compatible with custom TypeScript, Babel, and ESM. In what of these are you currently interested and what is your use-case? |
@mxschmitt I'm new to Playwright test running and simply trying to get an ESM test to run. I tried some other versions of I might be doing something wrong, but I actually can't get playwright to "find" .mjs files. Always reports no tests found. |
Yes, .mjs is not supported currently. We recommend TypeScript for now until we have added MJS support. |
Doubling down on #7066 We are considering to move from Mocha to Playwright's own test runner. With Mocha we were able to use |
#7452 is probably a dupe of this issue? I can't just use
|
My app uses module imports like
but these don't work in playwright out of the box (look below for a soloution) in Jest config I use
in tsconfig I have
And in playwright config I managed to get it working with
|
First, thanks for this tool! I can't use Playwright in an Angular project (with a classic official Angular CLI configuration), because of legacy decorators:
(so with
And as I didn't find a way to override the babel config, I'm stuck. More generally, it feels weird to be dependent on (complex) babel config files in a primary-TypeScript tool. It should at least do what's needed to respect the |
Hi, |
#7911 is the key pain point for me right now. I expect that I will need more support for customizing tsconfig.json, but the lack of module path mapping is a deal breaker in my codebase and prevents me from using playwright test within my standard typescript project. Has anyone found a way to workaround this and allow path aliases even if it is a complete hack? This is preventing me from using playwright with any references to our existing codebase which makes extensive use of path aliases to keep imports stable. |
I have also been getting this issue! We use openapi generation for our interfaces and http services. The problem for us was we were trying to use interfaces in the openapi folder (which we configured to use TS path in the tsconfig file). For some reason, playwright was trying to read ALL the files (including the services) and hence why we were getting the error. Fixed this by adjusting imports to use exact relative paths (not the ideal solution but it works). |
@bhanna1693 Thank you for your feedback. Unfortunately, except if if I'm missing something, your solution is okay if you just want to do e2e tests, but if you also want to use Playwright to do unit tests, then the service (and thus the decorator) has to be read. |
@cyrilletuzi oh yeah you would be correct |
Hi @pavelfeldman @mxschmitt, |
Please add module path mapping. For now, is there a workaround?
|
I have a monorepo with several TypeScript apps and I have avoided the use of Babel throughout. For testing I use I think playwright's test runner should do the same thing. |
I noticed that We want to use |
I have created a Playwright configuration for my monorepo. For now I am only interested in running e2e tests with Playwright. When I run |
Could you please file this separately? |
My work-around to avoid all the "../../../foo" noise is to first set the |
As an addition for paths support, decorators from tsconfig are also great feature which needs to be supported! |
Hello, any plans to fix this issue - the paths support? |
Should I file a separate issue for this? It's hard to track this meta-issue on what is planned and what is not. |
Hi, is there any plans to fix this? We are actively using decorators, paths and etc. Sure we can change paths, but what can we do with decorators? I believe that playwright should support all the range of options from tsconfig natively. |
Just to add, it seems support for module path mapping (#7911) also fails for jsconfig as well. (basically the same but throwing it out there). |
tsconfig-paths works to me for #7911 My tsconfig.json {
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "build",
"baseUrl": ".",
"paths": {
"@my/common-libs": [
"./modules/common-libs/src"
]
}
}
} Add a const tsConfig = require("./tsconfig.json");
const tsConfigPaths = require("tsconfig-paths");
const baseUrl = "./build/"; // Either absolute or relative path. If relative it's resolved to current working directory.
tsConfigPaths.register({
baseUrl,
paths: tsConfig.compilerOptions.paths
}); Then call playwright likes node -r ./tsconfig-paths-bootstrap.js ./node_modules/.bin/playwright test ... |
@awarecan Nice hack! But when tests are runing by CI systems you are not always may/want to deal with such things. |
I hope that I haven't miss out anything before writing this comment but is there any update on this issue? We are considering using Playwright test runner but this is a deal-breaker for us. |
Another alias solution for yarn users https://yarnpkg.com/features/protocols#why-is-the-link-protocol-recommended-over-aliases-for-path-mapping
|
@cameronbraid Pretty slick but in my specific case we're using |
I came across #7042, which has been folded into this issue. My use case - I have a monorepo with multiple packages. In one test, I'm attempting to import some data from one package to help build the test. That package happens to import from a third package. That third package also exports |
I have react app + |
I'd like to give an update on this issue since there has been some development, which is available in our nightly. It is also about to hit 1.18 RC later this week. I intend to close this metabug and open us to new bugs that would be targeting missing specifics. Please don't hesitate to file those.
npm i --save-dev @playwright/[email protected]
PW_EXPERIMENTAL_TS_ESM=1 npx playwright test Let us know whether it worked for you in a new bug with your expectations and repro steps, link this issue for context please! |
Hello, |
Please file new feature requests for it or create separate bug reports if you encounter issues. |
Module resolver issue extracted as #7066.
#7013
#7037
#7041
#7042
#7142
#7148
#7294
#7855
The text was updated successfully, but these errors were encountered: