Skip to content

Migrate storybook to v8 and its dependencies #207

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mocca102
Copy link
Contributor

Upgrading Storybook from version 7.6.20 to version 8.6.12..

How?

  • npx storybook@latest upgrade

What changed?

1. 🆙 Updated Node and NPM versions to LTS

2. ➕ Added

  • @storybook/manager-api and storybook/theming
  • Migration tool outputted Storybook packages used in your project, but they are missing from your project dependencies:

3. 🔁 Replaced

  • @storybook/jest and @storybook/testing-library with @storybook/test instead
  • The Packages are known to be incompatible since Storybook 8

4. ➖ Removed

  • argTypesRegex since it's deprecated

5. Webpack compiler setup

  • ➕ Added @storybook/addon-webpack5-compiler-babel
  • Installed babel presets
  • Webpack5 builder is now compiler agnostic, meaning you can choose a compiler addon that best fits your project
  • I choose Babel

6. 🆙 Upgraded storybook dependencies

  • @storybook/<something>

7. ➕ Added Visual Tests addon (It was recommended by the migration prompts)

  • @chromatic-com/storybook

8. 🔁 Removed

  • docs.autodocs setting in .storybook/main.js since it is deprecated
  • ➕ Added it to .storybook/preview.jsx instead

@mocca102 mocca102 requested a review from a team as a code owner April 21, 2025 20:52
@@ -1,11 +1,11 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was not required before but it breaks now if you don't import react

@@ -11,13 +11,11 @@
},
".": {
"import": "./lib/mjs/index.js",
"require": "./lib/cjs/index.js",
"types": "./lib/types/index.d.ts"
"require": "./lib/cjs/index.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The types import was ignored here. When I updated esbuild it threw the warning.

We already export all the types globally here

@mocca102 mocca102 removed the request for review from a team April 21, 2025 22:11
@mocca102
Copy link
Contributor Author

Interaction tests are only failing when ran in the CLI because of

After upgrading Storybook, the interaction tests are failing because they are blocked from firing Constructor events by our this.humanity.isBot() check

};

// @ts-ignore
// eslint-disable-next-line
window.navigator.__defineGetter__('webdriver', () => false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Override webdriver so our tracker module doesn't treat it as a bot and block tracking events

@@ -26,6 +26,11 @@ export default {
},
};

const explicitActionsSpies = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to set explicit spies for the actions

@mocca102 mocca102 requested a review from a team April 22, 2025 18:37
@@ -21,6 +21,8 @@ jobs:
node-version: '18.13.0'
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps # Downloads browser binaries + OS dependencies
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Playwright is required to download browser binaries for the interaction tests

@@ -1,4 +1,5 @@
const failOnConsole = require('jest-fail-on-console')
require('whatwg-fetch')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After updating jest I got an error that fetch is not defined so I added a fetch polyfill

"husky": "^8.0.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fail-on-console": "^3.3.0",
"license-checker": "^25.0.1",
"playwright": "^1.52.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed for the interaction tests

@esezen
Copy link
Contributor

esezen commented Apr 24, 2025

Are you also getting this while doing npm run dev? Should we look into it?

Screenshot 2025-04-24 at 9 45 27 PM

Also getting this when running npm run storybook:ci and it hangs there

Screenshot 2025-04-24 at 9 47 41 PM

@mocca102
Copy link
Contributor Author

Are you also getting this while doing npm run dev? Should we look into it?
...

Thank you for raising this @esezen

Yes, I do get it as well. This is happening because of the current Component Story Format (CSF). They need to be migrated to the updated CSF but this is having no real effect right now other than the warnings

This is an example of the changes needed to migrate to the new CSF format. Currently, we only have the index.stories.tsx files in the updated CSF format.
Screenshot 2025-04-24 at 11 04 15 PM

Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

2 participants