[REGRESSION]: '@playwright/experimental-ct-vue' package next branch alias setting seems to be ignored
Context:
- GOOD Playwright Version: 1.41
- BAD Playwright Version: 1.42 (next branch)
- Operating System: Windows 11
- Extra: Vite 5, this is important!
Code Snippet
...
ctViteConfig: {
plugins: getPlugins(),
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
}
},
},
...
Describe the bug
After updating to the next branch due to 1.41 compatibility issues with Vite 5, aliases no longer work.
Repro project is attached, just try running npm run test-ct in the terminal to see the error 'Cannot find package '@/helpers' imported from D:\Projects\vue-playwright-repro\src\App.spec.tsx'.
When using component testing, tests run in Node, while components run in the browser. Playwright tests are just a Node program, they don't run in the browser, they don't use Vite, test runner does not read and/or respect Vite config.
Playwright should respect the tsconfig path mappings though (as VS Code and all the other TS tools). I think we failed to resolve the reference to tsconfig.app.json, we should have picked the mapping from it. As a workaround, if you move the mapping into tsconfig.json explicitly, things should work.
(I don't believe this is a regression, rather a coincidence).
Oooh, yeah. Makes sense. So just a referenced tsconfig alias detection needs to be fixed.
I don't want to BS you, but I believe using aliased paths used to work in the component test spec files with the same setup. Not 100% sure though.
@pavelfeldman
I tried latest 'next' version (1.42.0-alpha-2024-02-06) but the same issue still persists.
I also verified code NPM fetched on my machine matches with the changes you made.
Did you test against the repro project after implementing the fix?
The workaround by moving compilerOptions.paths from tsconfig.app.json to tsconfig.json still works.
But the fix didn't really solve the problem. Must be some very minor thing though.