playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Getting "Please install @playwright/test package..." after upgrading from 1.34.0 to 1.34.1

Open mauricesnip opened this issue 2 years ago • 3 comments

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 by yarn 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

  1. Reinstalling @playwright/test
  2. Completely removing node_modules and reinstalling with yarn
  3. Works with yarn add @playwright/[email protected] -D
  4. Package playwright is not installed

mauricesnip avatar May 23 '23 08:05 mauricesnip

@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!

dgozman avatar May 24 '23 02:05 dgozman

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!

JoshuaKGoldberg avatar May 24 '23 06:05 JoshuaKGoldberg

@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!

@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

mauricesnip avatar May 24 '23 08:05 mauricesnip

👍 also seeing this issue

sarink avatar May 24 '23 18:05 sarink

Hey all, please update to 1.34.3 release that fixes this!

aslushnikov avatar May 25 '23 00:05 aslushnikov

Thanks for fixing this in such short notice! Works as expected with 1.34.3. 😊

mauricesnip avatar May 25 '23 07:05 mauricesnip

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]  

gg-hsi avatar May 25 '23 11:05 gg-hsi

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

thekp avatar May 25 '23 11:05 thekp

@gaaliche @thekp could you please file separately? It might be something else is going on; a repro would go a long way!

aslushnikov avatar May 25 '23 16:05 aslushnikov

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

zgordan-vv avatar Jun 04 '23 08:06 zgordan-vv

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.

voodoocreation avatar Jun 19 '23 23:06 voodoocreation

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.

RonyFluk-checksum avatar Aug 14 '23 08:08 RonyFluk-checksum