nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

Storybook Intereaction tests failing to run #19436

Closed louisjrdev closed 6 months ago

louisjrdev commented 1 year ago

Current Behavior

When running nx run componentlibrary:test-storybook the test suite failed to run with error: TypeError: this._resolver.getGlobalPaths is not a function

See screenshot of error from console: image

Expected Behavior

Storybook tests should run without error.

GitHub Repo

https://github.com/louisjrdev/nxstorybooktestbug

Steps to Reproduce

  1. npm install to install dependencies
  2. Run nx run componentlibrary:storybook
  3. Wait for that to finish building
  4. Run nx run componentlibrary:test-storybook
  5. See error in the console

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.15.0
   OS     : win32-x64
   npm    : 9.8.1

   nx (global)        : 16.9.1
   nx                 : 16.9.1
   @nx/js             : 16.9.1
   @nx/jest           : 16.9.1
   @nx/linter         : 16.9.1
   @nx/workspace      : 16.9.1
   @nx/angular        : 16.9.1
   @nx/cypress        : 16.9.1
   @nx/devkit         : 16.9.1
   @nx/eslint-plugin  : 16.9.1
   @nx/storybook      : 16.9.1
   @nrwl/tao          : 16.9.1
   @nx/web            : 16.9.1
   @nx/webpack        : 16.9.1
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @storybook/angular : 7.4.6

Failure Logs

nx run componentlibrary:test-storybook

 FAIL   browser: chromium  componentlibrary/src/lib/testcomponent/testcomponent.component.stories.ts
  ● 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)
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.819 s
Ran all test suites.
Warning: run-commands command "test-storybook -c componentlibrary/.storybook --url=http://localhost:4400" exited with non-zero status code

 ———————————————————————————————————————

 >  NX   Ran target test-storybook for project componentlibrary (3s)

    ×    1/1 failed
    √    0/1 succeeded [0 read from cache]

Package Manager Version

No response

Operating System

Additional Information

This issue was initially only happening in our production repo on CI builds and not locally, but was able to reproduce the issue locally in a new repo and workspace.

louisjrdev commented 1 year ago

I will note on this, our CI is running on Linux.

I was also able to get this working locally using Node 18.18.0 but then in our CI moved to that version the same error happens, so perhaps this is not producable 100% of the time, but it is fairly consistently failing across the board.

mandarini commented 1 year ago

@louisjrdev yes to be honest I could not reproduce on MacOS. I will try to get hold of a person on the team who has a windows machine, maybe they can repro. Sorry about that!

Also, this could be a bug on the Storybook side, since on Nx we're just directly invoking the Storybook test-runner. So any issue should be coming directly from there... Do you want to try and open an issue either on the Storybook test runner repo, or the Storybook repo?

kfern commented 1 year ago

Same here on Linux > NX Report complete - copy this into the issue template

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

mandarini commented 1 year ago

Thanks @kfern for reporting this! I am pretty sure this is an issue with test-runner, so thanks for creating an issue there!

meeroslav commented 1 year ago

FYI, the problem is with npm handling dependencies, not storybook or nx: https://github.com/storybookjs/test-runner/issues/366#issuecomment-1801762421

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

mandarini commented 6 months ago

I will be closing this now, but feel free to reopen if you verify that it's an issue with Nx (which it seems that it is not)!

github-actions[bot] commented 5 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.