Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: test-storybook fails when using yarn pnp #23654

Closed
MauriceNino opened this issue Jul 29, 2023 · 4 comments · Fixed by storybookjs/test-runner#432
Closed

[Bug]: test-storybook fails when using yarn pnp #23654

MauriceNino opened this issue Jul 29, 2023 · 4 comments · Fixed by storybookjs/test-runner#432

Comments

@MauriceNino
Copy link

Describe the bug

When trying to run yarn test-storybook in a Next.js project, using yarn pnp, I get the following error:

PlaywrightError: jest-playwright-preset: Cannot find playwright package to use chromium
    at getPlaywrightInstance (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/jest-playwright-preset-virtual-028de7a7f8/0/cache/jest-playwright-preset-npm-2.0.0-5c5b33e0e6-262e261c09.zip/node_modules/jest-playwright-preset/lib/utils.js:113:19)
    at PlaywrightRunner.getTests (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/jest-playwright-preset-virtual-028de7a7f8/0/cache/jest-playwright-preset-npm-2.0.0-5c5b33e0e6-262e261c09.zip/node_modules/jest-playwright-preset/lib/PlaywrightRunner.js:84:99)
    at PlaywrightRunner.runTests (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/jest-playwright-preset-virtual-028de7a7f8/0/cache/jest-playwright-preset-npm-2.0.0-5c5b33e0e6-262e261c09.zip/node_modules/jest-playwright-preset/lib/PlaywrightRunner.js:124:41)
    at async TestScheduler.scheduleTests (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/@jest-core-virtual-86f96f357a/0/cache/@jest-core-npm-28.1.3-4b9647f71c-cb79f34baf.zip/node_modules/@jest/core/build/TestScheduler.js:317:13)
    at async runJest (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/@jest-core-virtual-86f96f357a/0/cache/@jest-core-npm-28.1.3-4b9647f71c-cb79f34baf.zip/node_modules/@jest/core/build/runJest.js:407:19)
    at async _run10000 (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/@jest-core-virtual-86f96f357a/0/cache/@jest-core-npm-28.1.3-4b9647f71c-cb79f34baf.zip/node_modules/@jest/core/build/cli/index.js:339:7)
    at async runCLI (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/@jest-core-virtual-86f96f357a/0/cache/@jest-core-npm-28.1.3-4b9647f71c-cb79f34baf.zip/node_modules/@jest/core/build/cli/index.js:190:3)
    at async Object.run (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/__virtual__/jest-cli-virtual-3cf6179c47/0/cache/jest-cli-npm-28.1.3-aab5c7389d-fb424576bf.zip/node_modules/jest-cli/build/cli/index.js:155:37)
    at async executeJestPlaywright (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/cache/@storybook-test-runner-npm-0.12.0-7653174f80-bf8e463351.zip/node_modules/@storybook/test-runner/dist/test-storybook.js:128:3)
    at async main (/home/xxxxxx/xxxxxx/xxxxxx/.yarn/cache/@storybook-test-runner-npm-0.12.0-7653174f80-bf8e463351.zip/node_modules/@storybook/test-runner/dist/test-storybook.js:272:3)

To Reproduce

  1. Create a new Next.js project (in my case with TypeScript)
  2. Switch yarn to use pnp
  3. Add storybook
  4. Add storybook test runner
  5. Run yarn test-storybook

System

Environment Info:

  System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  Binaries:
    Node: 18.16.0 - ~/.asdf/installs/nodejs/18.16.0/bin/node
    Yarn: 3.6.1 - ~/.asdf/installs/nodejs/18.16.0/bin/yarn
    npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm

Additional context

When changing the nodeLinker to node-modules, the tests run without any problems.

@coopbri
Copy link

coopbri commented Aug 24, 2023

Same issue with pnpm linker (not to be confused with pnp). The node-modules linker worked for me as well, thanks for the workaround!

@anubhav7495
Copy link

I fixed it by running:

yarn add --dev jest-playwright-preset playwright

@coopbri
Copy link

coopbri commented Oct 16, 2023

I fixed it by running:

yarn add --dev jest-playwright-preset playwright

This works for me! Thank you so much!

@yannbf
Copy link
Member

yannbf commented Jan 31, 2024

Hey everyone, thanks for reporting this issue. Unfortunately there isn't much we can do to make the test-runner work out of the box because the issue lies on a dependency of the package instead (jest-playwright-preset), but the solutions are now documented in the README of the test-runner repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants