Skip to content

feat(storybook)!: support storybook 9 #31172

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

Coly010
Copy link
Contributor

@Coly010 Coly010 commented May 12, 2025

Current Behavior

We currently do not have support for Storybook 9, nor any migrations to help users switch to it.

Expected Behavior

Support Storybook 9 and add a migration for users to switch to v9

BREAKING CHANGE: Remove deprecated generators: @nx/storybook:cypress-project, @nx/react-native:storybook-configuration, @nx/react-native:stories, @nx/react-native:component-story

@Coly010 Coly010 self-assigned this May 12, 2025
Copy link

nx-cloud bot commented May 12, 2025

View your CI Pipeline Execution ↗ for commit da609d4.

Command Status Duration Result
nx nx-release @nx/nx-source --parallel 8 --loca... ✅ Succeeded 8m 15s View ↗
nx run-many -t build-native-wasm ✅ Succeeded 1m 30s View ↗
nx run-many --target=build-native -- --target=a... ✅ Succeeded 8m 19s View ↗
nx run-many --target=build-native -- --target=x... ✅ Succeeded 6m 28s View ↗
nx run-many --target=build-native -- --target=x... ✅ Succeeded 6m 26s View ↗
nx run-many --target=build-native -- --target=a... ✅ Succeeded 6m 54s View ↗
nx run-many --verbose --outputStyle stream --ta... ✅ Succeeded 6m 18s View ↗
nx run-many --target=build-native -- --target=a... ✅ Succeeded 4m 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-13 16:19:43 UTC

Copy link

vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview May 13, 2025 3:47pm

@yannbf
Copy link

yannbf commented May 12, 2025

Related to the generation of story files, e.g.:
https://github.com/search?q=repo%3Anrwl%2Fnx%20%40storybook%2Ftesting-library&type=code

here's a before/after code in case it helps!

- import type { Meta, StoryObj } from '@storybook/react';
+ import type { Meta, StoryObj } from '@storybook/react-webpack5'; // the "renderer" is gone, we use the "framework" now
import { MyButton } from './my-button';
- import { within } from '@storybook/testing-library';
- import { expect } from '@storybook/jest';
+ import { expect } from 'storybook/test'; // all test utilities are part of storybook now

const meta: Meta<typeof MyButton> = {
  component: MyButton,
  title: 'MyButton',
};
export default meta;
type Story = StoryObj<typeof MyButton>;

export const Heading: Story = {
  args: {
    text: '',
    padding: 0,
    disabled: false,
  },
-  play: async ({ canvasElement }) => {
+  play: async ({ canvas }) => { // the within + canvasElement thing happens internally now
-    const canvas = within(canvasElement);
-    expect(canvas.getByText(/Welcome to MyButton!/gi)).toBeTruthy();
+    await expect(canvas.getByText(/Welcome to MyButton!/gi)).toBeTruthy(); // this should be awaited
  },
};

@Coly010 Coly010 force-pushed the storybook/migrate-9 branch from 7bf118c to ab4c17a Compare May 13, 2025 09:23
…erator

BREAKING CHANGE: The `@nx/storybook:cypress-project` generator has been deprecated for some time and marked for removal in Nx 21. It has now been removed.
BREAKING CHANGE: @nx/react-native:stories generator removed as it is a pass through to @nx/react:stories. It has been deprecated and was supposed to be removed in Nx 19
@Coly010 Coly010 changed the title feat(storybook): support storybook 9 feat(storybook)!: support storybook 9 May 13, 2025
@Coly010 Coly010 force-pushed the storybook/migrate-9 branch from a42d64c to 75a3c8e Compare May 13, 2025 14:02
@Coly010 Coly010 force-pushed the storybook/migrate-9 branch from 75a3c8e to 8ddcbf3 Compare May 13, 2025 14:26
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-31172-da609d4
Release details 📑
Published version 0.0.0-pr-31172-da609d4
Triggered by @Coly010
Branch storybook/migrate-9
Commit da609d4
Workflow run 15001097854

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

"@storybook/svelte-vite",
"@storybook/sveltekit",
"@storybook/vue-webpack5",
"@storybook/vue-vite",
Copy link

Choose a reason for hiding this comment

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

vue-vite is also umaintained since Storybook 8, as it relates to Vue2 and lower

"@storybook/vue3-vite",
"@storybook/web-components-webpack5",
"@storybook/web-components-vite"
],
"aliases": ["storybook7UiFramework"],
Copy link

Choose a reason for hiding this comment

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

should this still be called storybook7?

const pm = getPackageManagerCommand(packageManager);

output.log({
title: 'Storybook 8 Migration Guide',
Copy link

Choose a reason for hiding this comment

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

Suggested change
title: 'Storybook 8 Migration Guide',
title: 'Storybook 9 Migration Guide',

output.log({
title: 'Storybook 8 Migration Guide',
bodyLines: [
`You can run the following commands manually to upgrade your Storybook projects to Storybook 8:`,
Copy link

Choose a reason for hiding this comment

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

Suggested change
`You can run the following commands manually to upgrade your Storybook projects to Storybook 8:`,
`You can run the following commands manually to upgrade your Storybook projects to Storybook 9:`,

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