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

TypeError: Jest: Got error running globalSetup - /[root]/node_modules/@storybook/test-runner/playwright/global-setup.js, reason: Class extends value #<Object> is not a constructor or null #18120

Closed
ryanbuckleyca opened this issue May 2, 2022 · 7 comments

Comments

@ryanbuckleyca
Copy link

ryanbuckleyca commented May 2, 2022

Describe the bug
When trying test-storybook, we get the following error:
TypeError: Jest: Got error running globalSetup - /[root]/node_modules/@storybook/test-runner/playwright/global-setup.js, reason: Class extends value #<Object> is not a constructor or null

the trace is:

    at Object.<anonymous> (/[root]/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:242:27)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.newLoader (/[root]/node_modules/pirates/lib/index.js:141:7)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/[root]/node_modules/jest-playwright-preset/index.js:1:18)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.newLoader (/[root]/node_modules/pirates/lib/index.js:141:7)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

To Reproduce
Run 'test-storybook' to see the above error:
Repository: https://github.com/ryanbuckleyca/sbbug
Deployed repo: https://sbbug.herokuapp.com/

System
(note, the same bug occurs in our development environment as well, so it is not specific to this system)

Environment Info:

System:
OS: macOS 12.3.1
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Binaries:
Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
npm: 8.7.0 - ~/.nvm/versions/node/v14.15.5/bin/npm
Browsers:
Firefox: 99.0.1
Safari: 15.4
npmPackages:
@storybook/addon-actions: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/addon-docs: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/addon-essentials: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/addon-interactions: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/addon-links: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/builder-webpack4: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/manager-webpack4: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/react: ^6.5.0-beta.1 => 6.5.0-beta.1
@storybook/testing-library: ^0.0.11 => 0.0.11

@v1s10n-4
Copy link

v1s10n-4 commented May 4, 2022

I got the same issue with:

"@storybook/jest": "^0.0.10",
"@storybook/test-runner": "^0.0.8",
"@storybook/testing-library": "^0.0.11",
"@storybook/addon-essentials": "^6.4.22",

it result as:

TypeError: Jest: Got error running globalSetup - /Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/@storybook/test-runner/playwright/global-setup.js, reason: Class extends value #<Object> is not a constructor or null
    at Object.getPlaywrightEnv (/Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:59:48)
    at Object.<anonymous> (/Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:242:27)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.newLoader (/Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/pirates/lib/index.js:141:7)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/jest-playwright-preset/index.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.newLoader (/Users/v1s10n_4/code/flaneer/app-flaneer/node_modules/pirates/lib/index.js:141:7)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

@v1s10n-4
Copy link

v1s10n-4 commented May 5, 2022

Looks like this issue is related to storybookjs/test-runner#99
According to this answer it can be fixed by matching some dependencies version needed by jest-playwright:

"jest": "^27.5.1",
"jest-runner": "^27.5.1",
"jest-environment-node": "27.5.1"

@ahnpnl
Copy link

ahnpnl commented May 24, 2022

Indeed with Jest 27 it is ok but Jest 28 throws error

@tomasfrancisco
Copy link

For me it also works with

"resolutions": { 
    "jest": "28.1.3",
    "jest-runner": "28.1.3",
    "jest-environment-node": "28.1.3"
}

@sparkeplug
Copy link

sparkeplug commented Dec 5, 2022

Just leaving my 2 cents here, hope it helps few folks.

  • My project uses CRA ( Create React App ) V.4.0.3, which has a dependency of JEST V.26.6.0 .
  • @storybook/test-runner versions ^0.7.0 expects jest 28.

Got the same error as mentioned in this ticket.

Hence downgraded the @storybook/test-runner version to V.0.6.4, which is the last version to have a dependency of Jest less than V.28.

It works.

@janakunft
Copy link

janakunft commented Dec 28, 2022

Just leaving my 2 cents here, hope it helps few folks.

  • My project uses CRA ( Create React App ) V.4.0.3, which has a dependency of JEST V.26.6.0 .
  • @storybook/test-runner versions ^7.0 expects jest 28.

Got the same error as mentioned in this ticket.

Hence downgraded the @storybook/test-runner version to V.6.0.4, which is the last version to have a dependency of Jest less than V.28.

It works.

This has resolved my issue, thank you very much! Just a small comment - there is a typo in your post, it's v0.6.4 test-runner needs to be downgraded to

@Victor-Nyagudi
Copy link

Just leaving my 2 cents here, hope it helps few folks.

  • My project uses CRA ( Create React App ) V.4.0.3, which has a dependency of JEST V.26.6.0 .
  • @storybook/test-runner versions ^0.7.0 expects jest 28.

Got the same error as mentioned in this ticket.

Hence downgraded the @storybook/test-runner version to V.0.6.4, which is the last version to have a dependency of Jest less than V.28.

It works.

I'm in the same boat i.e using Create React App. Downgrading @storybook/test-runner to version 0.6.4 worked for me.

olivercaine added a commit to olivercaine/react-redux-starter-kit-extended that referenced this issue Oct 18, 2023
…). Upgraded to v29 but it requires Node 14.5 and above so also updating GitHub workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants