-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Release: Prerelease 9.2.0-alpha.2 #32186
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
Changes from all commits
47f55fb
29048f6
e4cd834
8483d0b
c8088d9
f6868f0
58db607
f08fe97
f148fae
84ea113
32fbe3a
53046fe
74aa094
d92b88a
404c4f3
7ad8911
8a3bc56
94ef419
479765e
b6edefe
022ad9e
8c8bdc5
ead67db
738ca0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,5 +285,6 @@ | |
| "Dependency Upgrades" | ||
| ] | ||
| ] | ||
| } | ||
| }, | ||
| "deferredNextVersion": "9.2.0-alpha.2" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| ```ts filename="Page.stories.ts" renderer="angular" language="ts" | ||
| import type { Meta, StoryObj } from '@storybook/angular'; | ||
|
|
||
| import { Page } from './Page'; | ||
|
|
||
| const meta: Meta<Page> = { | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }; | ||
| export default meta; | ||
|
|
||
| type Story = StoryObj<Page>; | ||
|
|
||
| export const Default: Story = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```svelte filename="Page.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" | ||
| <script module> | ||
| import { defineMeta } from '@storybook/addon-svelte-csf'; | ||
|
|
||
| import Page from './Page.svelte'; | ||
|
|
||
| const meta = defineMeta({ | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }); | ||
| </script> | ||
|
|
||
| <Story name="Default" play={async ({ canvas }) => { | ||
| // ... | ||
| }} | ||
| /> | ||
| ``` | ||
|
|
||
| ```js filename="Page.stories.js" renderer="svelte" language="js" tabTitle="CSF" | ||
| import Page from './Page.svelte'; | ||
|
|
||
| export default { | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }; | ||
|
|
||
| export const Default = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```js filename="Page.stories.js" renderer="common" language="js" | ||
| import { Page } from './Page'; | ||
|
|
||
| export default { | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }; | ||
|
|
||
| export const Default = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```svelte filename="Page.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" | ||
| <script module> | ||
| import { defineMeta } from '@storybook/addon-svelte-csf'; | ||
|
|
||
| import Page from './Page.svelte'; | ||
|
|
||
| const meta = defineMeta({ | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }); | ||
| </script> | ||
|
|
||
| <Story name="Default" play={async ({ canvas }) => { | ||
| // ... | ||
| }} | ||
| /> | ||
| ``` | ||
|
|
||
| ```ts filename="Page.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" | ||
| // Replace your-framework with svelte-vite or sveltekit | ||
| import type { Meta, StoryObj } from '@storybook/your-framework'; | ||
|
|
||
| import Page from './Page.svelte'; | ||
|
|
||
| const meta = { | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| } satisfies Meta<typeof Page>; | ||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```ts filename="Page.stories.ts" renderer="common" language="ts" | ||
| // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc. | ||
| import type { Meta, StoryObj } from '@storybook/your-framework'; | ||
|
|
||
| import { Page } from './Page'; | ||
|
|
||
| const meta = { | ||
| component: Page, | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| } satisfies Meta<typeof Page>; | ||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```js filename="Page.stories.js" renderer="web-components" language="js" | ||
| export default { | ||
| component: 'my-page', | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }; | ||
|
|
||
| export const Default = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```ts filename="Page.stories.ts" renderer="web-components" language="ts" | ||
| import type { Meta, StoryObj } from '@storybook/web-components-vite'; | ||
|
|
||
| const meta: Meta = { | ||
| component: 'my-page', | ||
| // 👇 Runs after each story in this file | ||
| async afterEach(context) { | ||
| console.log(`✅ Tested ${context.name} story`); | ||
| }, | ||
| }; | ||
| export default meta; | ||
|
|
||
| type Story = StoryObj; | ||
|
|
||
| export const Default: Story = { | ||
| async play({ canvas }) { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ```ts filename=".storybook/preview.ts" renderer="common" language="ts" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Automatically replaces all exports from the `lib/session` local module with mock functions | ||
| sb.mock(import('../lib/session.ts')); | ||
| // 👇 Automatically replaces all exports from the `uuid` package in `node_modules` with mock functions | ||
| sb.mock(import('uuid')); | ||
|
|
||
| // ...rest of the file | ||
| ``` | ||
|
|
||
| ```js filename=".storybook/preview.js" renderer="common" language="js" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Automatically replaces all exports from the `lib/session` local module with mock functions | ||
| sb.mock('../lib/session.js'); | ||
| // 👇 Automatically replaces all exports from the `uuid` package in `node_modules` with mock functions | ||
| sb.mock('uuid'); | ||
|
|
||
| // ...rest of the file | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ```ts filename=".storybook/preview.ts" renderer="common" language="ts" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Replaces imports of this module with imports to `../lib/__mocks__/session.ts` | ||
| sb.mock(import('../lib/session.ts')); | ||
| // 👇 Replaces imports of this module with imports to `../__mocks__/uuid.ts` | ||
| sb.mock(import('uuid')); | ||
|
|
||
| // ...rest of the file | ||
| ``` | ||
|
|
||
| ```js filename=".storybook/preview.js" renderer="common" language="js" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Replaces imports of this module with imports to `../lib/__mocks__/session.ts` | ||
| sb.mock('../lib/session.js'); | ||
| // 👇 Replaces imports of this module with imports to `../__mocks__/uuid.ts` | ||
| sb.mock('uuid'); | ||
|
Comment on lines
+16
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: File extension mismatch: comment references session.ts and uuid.ts but the actual mock calls use .js extension. The comments should match the implementation. |
||
|
|
||
| // ...rest of the file | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ```ts filename=".storybook/preview.ts" renderer="common" language="ts" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Automatically spies on all exports from the `lib/session` local module | ||
| sb.mock(import('../lib/session.ts'), { spy: true }); | ||
| // 👇 Automatically spies on all exports from the `uuid` package in `node_modules` | ||
| sb.mock(import('uuid'), { spy: true }); | ||
|
Comment on lines
+5
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: TypeScript version uses |
||
|
|
||
| // ...rest of the file | ||
| ``` | ||
|
|
||
| ```js filename=".storybook/preview.js" renderer="common" language="js" | ||
| import { sb } from 'storybook/test'; | ||
|
|
||
| // 👇 Automatically spies on all exports from the `lib/session` local module | ||
| sb.mock('../lib/session.js', { spy: true }); | ||
| // 👇 Automatically spies on all exports from the `uuid` package in `node_modules` | ||
| sb.mock('uuid', { spy: true }); | ||
|
|
||
| // ...rest of the file | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent file extensions in comments - session.ts mock but uuid.ts for JavaScript package. Consider using .js for consistency in JS examples or clarify the extension handling.