test-runner icon indicating copy to clipboard operation
test-runner copied to clipboard

[bug] Storybook Interaction tests failing to run: getGlobalPaths is not a function

Open kfern opened this issue 1 year ago • 1 comments

Describe the bug

Interaction tests works fine with storybook

From command line (test-storybook -c ui-components/.storybook --url=http://localhost:4400)

 FAIL   browser: chromium  ui-components/src/lib/welcome/welcome.stories.tsx
  ● Test suite failed to run
    TypeError: this._resolver.getGlobalPaths is not a function
      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1392:40)

To Reproduce I'm using nx on Linux. It doesn't seem to happen in all cases.

This bug is related wtih https://github.com/nrwl/nx/issues/19436#issuecomment-1748919488

Also, this could be a bug on the Storybook side, since on Nx we're just directly invoking the Storybook test-runner

Expected behavior Tests runs without errors

Screenshots If applicable, add screenshots to help explain your problem.

System Please paste the results of npx storybook@latest info here.

Environment Info:

System: OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish) CPU: redacted Binaries: Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node Yarn: 1.22.5 - /usr/bin/yarn npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm Browsers: Chrome: 111.0.5563.110 npmPackages: @storybook/addon-essentials: ^7.2.1 => 7.4.6 @storybook/addon-interactions: ^7.2.1 => 7.4.6 @storybook/core-server: ^7.2.1 => 7.4.6 @storybook/jest: ~0.1.0 => 0.1.0 @storybook/react-vite: ^7.2.1 => 7.4.6 @storybook/test-runner: ^0.13.0 => 0.13.0 @storybook/testing-library: ~0.2.0 => 0.2.2

Additional context NX Report

Node : 18.18.0 OS : linux-x64 npm : 9.8.1

nx (global) : 16.10.0 nx : 16.10.0 @nx/js : 16.10.0 @nx/jest : 16.10.0 @nx/linter : 16.10.0 @nx/workspace : 16.10.0 @nx/cypress : 16.10.0 @nx/devkit : 16.10.0 @nx/eslint-plugin : 16.10.0 @nx/next : 16.10.0 @nx/playwright : 16.10.0 @nx/react : 16.10.0 @nx/storybook : 16.10.0 @nrwl/tao : 16.10.0 @nx/vite : 16.10.0 @nx/web : 16.10.0 typescript : 5.1.6

kfern avatar Oct 16 '23 09:10 kfern

The problem seems to be with npm, not necessarily storybook.

The latest @storybook/test-runner depends on jest-runner@v28 which depends on jest-runtime@v28, but it ends up referencing the hoisted jest-runtime@v29 if you have hoisted jest@v29.

This is not a problem with yarn or pnpm since they do a proper isolation of the package dependencies.

That being said, based on the package.json I expect this to land in 0.14.0 version.

meeroslav avatar Nov 08 '23 12:11 meeroslav