playwright
playwright copied to clipboard
[BUG] Getting "Please install @playwright/test package..." after upgrading from 1.34.0 to 1.34.1
System info
- Playwright Version: v1.34.1
- Operating System: macOS 13.2.1
- Browser: N/A
- Other info: Terminal, CLI, Node 18.16.0 LTS
Source code
Config file
// playwright.config.js
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
preserveOutput: 'failures-only',
snapshotPathTemplate: '{testDir}/__snapshots__/{testFilePath}/{arg}{ext}',
testDir: './assets',
use: {
viewport: {
width: 1440,
height: 900,
},
},
});
Test file (self-contained)
Simple tests like:
test('builds CSS correctly', () => {
expect(fs.readFileSync(`${PUBLIC_PATH}${MANIFEST['build/app/app.css']}`, 'utf-8')).toMatchSnapshot();
});
test('renders homepage correctly', async ({ page }) => {
await page.goto('<REMOVED_URL>');
await expect(page).toHaveScreenshot({ fullPage: true });
});
// Etc...
Steps
- Run
npx playwright test(executed byyarn test)
Expected
To start running tests by executing npx playwright test, like it did in previous versions (1.34.0 and down).
Actual
Getting the following message:
➜ yarn test
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
Already rules out a few things
- Reinstalling
@playwright/test - Completely removing
node_modulesand reinstalling withyarn - Works with
yarn add @playwright/[email protected] -D - Package
playwrightis not installed
@mauricesnip Could you please share a repository where this happens? We believe this issue has been fixed in v1.34.1 and v1.34.2, but you say it has regressed instead. It would be great to see the setup that leads to this!
https://github.com/dylans/halfstackconf-next/tree/6f4f208b4e2e172fd7bd47e6543bcf50feed512f -> shows this issue https://github.com/dylans/halfstackconf-next/actions/runs/5065467209/jobs/9094073764:
> [email protected] test:ci /home/runner/work/halfstackconf-next/halfstackconf-next
> playwright test
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
ELIFECYCLE Command failed with exit code 1.
...then uninstalling the playwright package fixed it: dylans/halfstackconf-next@e466ac7 (#65) -> https://github.com/dylans/halfstackconf-next/actions/runs/5065495755/jobs/9094128846?pr=65 ✅
# For npm users: npm rm playwright
pnpm rm playwright`
@cyrilletuzi's https://github.com/Microsoft/playwright/issues/6981#issuecomment-857499483 was what fixed it. Thanks!
@mauricesnip Could you please share a repository where this happens? We believe this issue has been fixed in
v1.34.1andv1.34.2, but you say it has regressed instead. It would be great to see the setup that leads to this!
@dgozman Sure thing! In my case, the issue actually started from 1.34.1 and up. I've added a reduced test case which is using 1.34.2. See README for details: https://github.com/mauricesnip/23228-playwright-test-case
Addendum
I got the following message after initial yarn install and trying to run yarn test:
~/repositories/23228-playwright-test-case via ⬢ v18.16.0 on 🐳 v20.10.24 (desktop-linux) took 3s
➜ yarn test
Need to install the following packages:
[email protected]
Ok to proceed? (y)
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
👍 also seeing this issue
Hey all, please update to 1.34.3 release that fixes this!
Thanks for fixing this in such short notice! Works as expected with 1.34.3. 😊
The issue is still there
❯ y test:Chrome
yarn run v1.22.19
$ playwright test --project='Desktop Chrome'
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
the package was updated to the latest
❯ y list --pattern @playwright/test
yarn list v1.22.19
└─ @playwright/[email protected]
Hi, I'm also still facing this issue.
$ node -v
v19.4.0
$ yarn -v
1.22.19
$ yarn list --pattern @playwright/test
yarn list v1.22.19
└─ @playwright/[email protected]
Also, I tried using an older version of @playwright/test and playwright at version 1.33.0 but I still got the same error when trying to run playwright test locally:
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
@gaaliche @thekp could you please file separately? It might be something else is going on; a repro would go a long way!
Upgrading to @playwright/[email protected] didn't help as well. Playwright is not installed, only [email protected].
yarn -v
1.22.19
node -v
v16.20.0
What seemed to fix this for me was to ensure that @playwright/test was installed, plus ensuring that playwright was removed from the project's direct dependencies - I think having both packages installed may have been the cause in my case.
Getting this error as well.
What about projects that use both the playwright/test and the playwright packages?
Edit: fixed solution by removing the playwright library - the package simply wraps playwright-core which is a shared library and is already added as a dependency when installing playwright/test.
So in the code I updated imports from playwright to import from playwright-code, and voila, everything works.