Skip to content

Conversation

skitterm
Copy link
Member

@skitterm skitterm commented May 6, 2025

Issue: #AP-6003

What Changed

Storybook (which is used internally by the e2e packages) upgraded from 8.6.0 to 9.0.0.

I ran the yarn dlx storybook@next upgrade command and accepted all the suggested migrations.

Main thing that changed (manually) was getting rid of @storybook/eslint-config-storybook and using the recommended eslint-plugin-storybook. This took some copy-pasta of configs from that removed package's eslintrc.js in order to get the same configuration that we had before.

Also changed Node.js version used in CI workflows -- Storybook 9 doesn't support Node 18, so it's upgraded to pull the latest (cached) LTS version of node so we don't have to keep updating the files every year or two.

How to test

Playwright

  • In an existing e2e project (that uses Chromatic), download the canary version of the @chromatic-com/playwright package
  • Commit the package.json/package lock change without adding any UI changes
  • Locally, run Playwright
  • Locally, run archive-storybook
  • Verify the Storybook loads up with the stories as expected
  • Run the Chromatic command
  • Verify that the Chromatic build completes with no visual changes

Cypress

  • Same steps as Playwright, but with @chromatic-com/cypress package

@skitterm skitterm changed the title To sbv9 Upgrade Storybook to v9 May 6, 2025
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (539e48a) to head (1aaf069).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #252      +/-   ##
==========================================
+ Coverage   95.64%   95.87%   +0.23%     
==========================================
  Files          14       14              
  Lines         390      388       -2     
  Branches       66       64       -2     
==========================================
- Hits          373      372       -1     
+ Misses         17       16       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +2 to +14
extends: ['plugin:@typescript-eslint/recommended', 'plugin:storybook/recommended'],
plugins: ['import'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx', '.mjs', '.d.ts'],
paths: ['node_modules/', 'node_modules/@types/'],
},
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this (minus the plugin:storybook/recommended which is the new storybook ESLint config) is to account for the fact that we're not using @storybook/eslint-config-storybook anymore.

Internally @storybook/eslint-config-storybook was doing all this and much more.

Same goes for the other 3 eslintrc files as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge deal but is there some way to share eslint configs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good point. I think we should, since we had to update this in 4 places and the same applies whenever we upgrade to ESLint v9. I'll see if there's a simple way!

Copy link
Member Author

@skitterm skitterm May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmeasday we can do this with a shared ESLint configuration, but adding that would bloat this PR (new workspace package for the shared config, publish it to NPM, etc). Are you OK if we wait to tackle the config-reuse for whenever we upgrade to ESLint v9 (which has a new config file format)?

@skitterm skitterm requested review from yannbf, tmeasday and tevanoff May 6, 2025 00:24
@skitterm
Copy link
Member Author

skitterm commented May 6, 2025

Hm, the locally-run (non-built) archived storybook (run by running yarn build && yarn test:playwright, then yarn archive-storybook:playwright) loads fine, but the version where we build the storybook (used by this CI check) is failing for some reason. I'll have to investigate this tomorrow.

@skitterm skitterm marked this pull request as ready for review May 6, 2025 00:31
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to include on the PR description that this also updates support in our archive-storybook package to also support 9+ (is that correct)?

LGTM, but we might want to test a canary against projects using both SB8 and 9 (and maybe <8.6 following this thread?)

Comment on lines +2 to +14
extends: ['plugin:@typescript-eslint/recommended', 'plugin:storybook/recommended'],
plugins: ['import'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx', '.mjs', '.d.ts'],
paths: ['node_modules/', 'node_modules/@types/'],
},
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge deal but is there some way to share eslint configs?

@skitterm
Copy link
Member Author

skitterm commented May 6, 2025

Yippee, figured out the issue -- We were specifically targeting node 18 in our CI workflow, but Storybook 9 requires node 20 or above. Updating our CI scripts to reflect that.

@skitterm
Copy link
Member Author

skitterm commented May 7, 2025

@tevanoff this is ready for your review! I'm assuming we don't need to bump the package versions since Storybook is an internal dependency, but happy to get your take on that.

@skitterm
Copy link
Member Author

skitterm commented May 7, 2025

I'm assuming we don't need to bump the package versions since Storybook is an internal dependency, but happy to get your take on that.

I'm realizing that we'd at least want to bump the package some version -- even though this is an internal change, it is a change nonetheless. I'll bump the minor version.

@skitterm
Copy link
Member Author

skitterm commented May 9, 2025

@tevanoff this is ready for your re-review -- I'm holding off on merging until I've tested more permutations of Storybook 8 and 9 together, but I've confirmed that a typical Cypress+Playwright codebase that upgrades to (indirectly) use Storybook 9 works fine with builds and storybooks.

@skitterm skitterm force-pushed the to-sbv9 branch 2 times, most recently from aec08dc to f39350a Compare May 12, 2025 23:55
// reference the entry file based on the package.json `bin` value, since it changed between SB 8.1 and 8.2
return resolve(dirname(require.resolve('storybook/package.json')), packageJson.bin.storybook);
return resolve(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to try a similar approach to this:
https://github.com/storybookjs/test-runner/blob/next/src/test-storybook.ts#L128

So that the resolution will start from the node_modules of the e2e package instead. If a user had something like this:

/node_modules
|_/storybook
|_/chromatic-e2e
|__/node_modules
|___/storybook

it will prefer the one from chromatic-e2e

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skitterm @tevanoff have you considered my suggestion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yannbf we decided to forego putting e2e on Storybook 9 for the time being. I'll close this PR to reflect that.

tevanoff added 2 commits May 27, 2025 15:32
This also includes them as dev dependencies in the root project
so that we can run our own E2E tests.
@tevanoff tevanoff force-pushed the to-sbv9 branch 2 times, most recently from c8b6eaf to 9754aae Compare May 28, 2025 19:32
Copy link
Member Author

@skitterm skitterm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tevanoff and @winkerVSbecks thanks for the progress!

@tevanoff my comments are "notes for us", let me know if you'd like me to resolve them or leave them to you.

@skitterm
Copy link
Member Author

Closing this as we decided, in the short term, to forego upgrading to Storybook 9 for the time being. We will revisit this when either a) we have a better handle on the level of effort to build our own custom Storybook framework, or b) Storybook 10 comes out.

@skitterm skitterm closed this Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants