Open skamansam opened 3 weeks ago
Hi Sam! I can reproduce, but I think everything's working as intended. If you add type: "module"
to package.json, you'll have to use import.meta.url
instead of __dirname
. This is classic Node.js behaviour and not specific to Playwright.
You link to a Vite FAQ entry, but I don't think that's related. Playwright uses Vite under the hood for component testing, but the repro doesn't include component tests. Also, I think the FAQ entry is about changes to Vite's library API, not about the kinds of projects it can bundle.
Could you elaborate on why you think this is related to changes in Vite?
Here is what happens when I run vite without type
: "module"` present -
pnpm dev
> redshred-dashboard@2.0.0b20220805110057 dev /home/sam/workspace/dashboard
> vite --mode development --host
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
VITE v5.4.2 ready in 196 ms
My real issue is that the default playwright config has the CJS build's usage commented out (with instructions), but doesn't include anything about the non-CJS build.
Version
1.46.1
Steps to reproduce
"type": "module",
to package.jsonnpx playwright test
Expected behavior
The tests to run successfully
Actual behavior
Additional context
For Vite, the CJS build is deprecated. see https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more info.
This can be fixed by changing that line to:
Environment