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]: @storybook/addon-storyshots is not compatible with react 18 #19541

Closed
barroudjo opened this issue Oct 19, 2022 · 10 comments
Closed

[Bug]: @storybook/addon-storyshots is not compatible with react 18 #19541

barroudjo opened this issue Oct 19, 2022 · 10 comments

Comments

@barroudjo
Copy link

Describe the bug

storyshots with react v18 throws react-test-renderer TypeError: Cannot read properties of undefined

This is due to @storybook/[email protected] having the following dependency for react-test-renderer: ^16.8.0 || ^17.0.0 which is incompatible with react v18.

Using resolutions in package.json solves the problem, but it should really be solved in @storybook/addon-storyshots dependencies by allowing react-test-renderer@18.
"resolutions": { "react-test-renderer": "18.2.0" }

To Reproduce

System

No response

Additional context

No response

@KorySchneider
Copy link
Contributor

KorySchneider commented Oct 20, 2022

The resolutions workaround did not work for me, but updating @storybook/addon-storyshots and @storybook/addon-storyshots-puppeteer to @future (currently 7.0.0-alpha.40) seems to have fixed it.

@shilman It would be great to get this change released on 6.x, I'm not terribly happy about having storyshot deps on an unstable version while all the other storybook deps are on 6.x

Copy link
Member

shilman commented Oct 24, 2022

@KorySchneider pretty sure that would be a breaking change. any idea why the resolutions workaround didn't work?

@KorySchneider
Copy link
Contributor

@shilman Ah I see. Not sure why the resolutions didn't work...I'm using pnpm so potentially a bug with that?

Copy link
Member

shilman commented Oct 24, 2022

@KorySchneider did you try overrides? https://pnpm.io/package_json#pnpmoverrides

@KorySchneider
Copy link
Contributor

@shilman Yep that's what I used. resolutions is just an alias for overrides. I tried it two ways:

"overrides": {
  "react-test-renderer": "18.2.0"
}

and

"overrides": {
  "@storybook/addon-storyshots>react-test-renderer": "18.2.0"
}

@barroudjo
Copy link
Author

barroudjo commented Oct 24, 2022 via email

@KorySchneider
Copy link
Contributor

@barroudjo I believe I did but I'll try it again soon and see what I see. What I do remember is that in the logs, the TypeError was coming from [email protected] (with the overrides set in package.json)

@coolboy0961
Copy link

coolboy0961 commented Nov 10, 2022

This solution fixed my problem.

"overrides": {
"react-test-renderer": "18.2.0"
}

steps

  1. add overrides setting in package.json
  2. delete node_modules and package-lock.json
  3. npm install
  4. execute npx jest --clearCache
  5. npm run test

@barroudjo
Copy link
Author

This solution fixed my problem.

"overrides": { "react-test-renderer": "18.2.0" }

steps

  1. add overrides setting in package.json
  2. delete node_modules and package-lock.json
  3. npm install
  4. execute npx jest --clearCache
  5. npm run test

Yeah my bad, my solution with "resolutions": { "react-test-renderer": "18.2.0" } was for yarn, the solution if you use npm is "overrides": { "react-test-renderer": "18.2.0" }

@jonniebigodes
Copy link
Contributor

The Storyshots addon is officially deprecated and will be removed in a future release of Storybook. To help with the transition process, we've created a migration guide for the available options and common use cases.

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

5 participants