-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
Version
1.45.0
Steps to reproduce
-
Start a fresh Debian dev container in VS Code.
-
Install Node.js via the instructions at https://github.com/nodesource/distributions?tab=readme-ov-file#installation-instructions-deb.
-
Enable Corepack via
sudo corepack enable. -
Initialize a Playwright project via
pnpm create playwright. Note that it uses@playwright/test. -
Install the Playwright Test extension (https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright).
-
Go to the Testing tab and observe that
tests/example.spec.tsis listed as expected.
-
Run
pnpm remove @playwright/test && pnpm add --save-dev @playwright/experimental-ct-react. -
Go to the Testing tab and observe that
tests/example.spec.tsis no longer detected when using@playwright/experimental-ct-reactinstead of@playwright/test.
Expected behavior
I expect the Playwright Test extension for VS Code to work the same whether I'm using @playwright/test or @playwright/experimental-ct-react.
Actual behavior
The Playwright Test extension for VS Code works with @playwright/test but not with @playwright/experimental-ct-react.
Additional context
If we take a look at https://github.com/microsoft/playwright-vscode/blob/v1.1.7/src/playwrightFinder.ts#L33, we see that the VS Code extension is trying to load @playwright/experimental-ct-react's package.json file as follows:
packageJSONPath = require.resolve(path.join(packageName, 'package.json'), { paths: [process.cwd()] });This is fine for @playwright/test since it exports package.json:
playwright/packages/playwright-test/package.json
Lines 17 to 27 in 4089f45
| "exports": { | |
| ".": { | |
| "types": "./index.d.ts", | |
| "import": "./index.mjs", | |
| "require": "./index.js", | |
| "default": "./index.js" | |
| }, | |
| "./cli": "./cli.js", | |
| "./package.json": "./package.json", | |
| "./reporter": "./reporter.js" | |
| }, |
However, this doesn't work for @playwright/experimental-ct-react since it doesn't export package.json:
playwright/packages/playwright-ct-react/package.json
Lines 17 to 30 in 4089f45
| "exports": { | |
| ".": { | |
| "types": "./index.d.ts", | |
| "default": "./index.js" | |
| }, | |
| "./register": { | |
| "types": "./register.d.ts", | |
| "default": "./register.mjs" | |
| }, | |
| "./hooks": { | |
| "types": "./hooks.d.ts", | |
| "default": "./hooks.mjs" | |
| } | |
| }, |
Indeed, if we run that line of code in a test script, we encounter the following error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /workspaces/debian/node_modules/@playwright/experimental-ct-react/package.json
Suggested fix
The fix should be as simple as adding a "./package.json": "./package.json" entry to the exports section of @playwright/experimental-ct-react's package.json file.
Note that you'll probably want to do the same for the other @playwright/experimental-ct-* packages as well.
Environment
System:
OS: Linux 6.6 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (12) arm64 unknown
Memory: 19.30 GB / 23.44 GB
Container: Yes
Binaries:
Node: 22.3.0 - /usr/bin/node
npm: 10.8.1 - /usr/bin/npm
pnpm: 9.4.0 - /usr/bin/pnpm
IDEs:
VSCode: 1.90.2 - /vscode/vscode-server/bin/linux-arm64/5437499feb04f7a586f677b155b039bc2b3669eb/bin/remote-cli/code
Languages:
Bash: 5.1.4 - /bin/bash
npmPackages:
@playwright/experimental-ct-react: ^1.45.0 => 1.45.0
