Skip to content

Commit 737cabc

Browse files
Merge pull request #32231 from storybookjs/docs_snippets_fix_incorrect_csf_constructs
Docs: Fix incorrect CSF constructs
2 parents 7e7e513 + b1d992e commit 737cabc

File tree

4 files changed

+94
-28
lines changed

4 files changed

+94
-28
lines changed

docs/_snippets/my-component-exclude-tags.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js" tabTitle="story"
1+
```ts filename="MyComponent.stories.ts" renderer="angular" language="ts"
2+
import type { Meta, StoryObj } from '@storybook/angular';
3+
4+
import { MyComponent } from './MyComponent.component';
5+
6+
const meta: Meta<MyComponent> = {
7+
component: MyComponent,
8+
//👇 Provides the `no-tests` tag to all stories in this file
9+
tags: ['no-tests'],
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<MyComponent>;
14+
15+
export const ExcludeStory: Story = {
16+
//👇 Adds the `no-tests` tag to this story to exclude it from the tests when enabled in the test-runner configuration
17+
tags: ['no-tests'],
18+
};
19+
```
20+
21+
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js"
222
import { MyComponent } from './MyComponent';
323

424
export default {
525
component: MyComponent,
6-
tags: ['no-tests'], // 👈 Provides the `no-tests` tag to all stories in this file
26+
//👇 Provides the `no-tests` tag to all stories in this file
27+
tags: ['no-tests'],
728
};
829

930
export const ExcludeStory = {
@@ -12,19 +33,20 @@ export const ExcludeStory = {
1233
};
1334
```
1435

15-
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts" tabTitle="story"
36+
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts"
1637
// Replace your-framework with the name of your framework
1738
import type { Meta, StoryObj } from '@storybook/your-framework';
1839

1940
import { MyComponent } from './MyComponent';
2041

21-
const meta: Meta<typeof MyComponent> = {
42+
const meta = {
2243
component: MyComponent,
23-
tags: ['no-tests'], // 👈 Provides the `no-tests` tag to all stories in this file
24-
};
44+
//👇 Provides the `no-tests` tag to all stories in this file
45+
tags: ['no-tests'],
46+
} satisfies Meta<typeof MyComponent>;
2547

2648
export default meta;
27-
type Story = StoryObj<typeof MyComponent>;
49+
type Story = StoryObj<typeof meta>;
2850

2951
export const ExcludeStory: Story = {
3052
//👇 Adds the `no-tests` tag to this story to exclude it from the tests when enabled in the test-runner configuration

docs/_snippets/my-component-include-tags.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js" tabTitle="story"
1+
```ts filename="MyComponent.stories.ts" renderer="angular" language="ts"
2+
import type { Meta, StoryObj } from '@storybook/angular';
3+
4+
import { MyComponent } from './MyComponent.component';
5+
6+
const meta: Meta<MyComponent> = {
7+
component: MyComponent,
8+
//👇 Provides the `test-only` tag to all stories in this file
9+
tags: ['test-only'],
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<MyComponent>;
14+
15+
export const IncludeStory: Story = {
16+
//👇 Adds the `test-only` tag to this story to be included in the tests when enabled in the test-runner configuration
17+
tags: ['test-only'],
18+
};
19+
```
20+
21+
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js"
222
import { MyComponent } from './MyComponent';
323

424
export default {
525
component: MyComponent,
6-
tags: ['test-only'], // 👈 Provides the `test-only` tag to all stories in this file
26+
//👇 Provides the `test-only` tag to all stories in this file
27+
tags: ['test-only'],
728
};
829

930
export const IncludeStory = {
@@ -12,19 +33,20 @@ export const IncludeStory = {
1233
};
1334
```
1435

15-
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts" tabTitle="story"
36+
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts"
1637
// Replace your-framework with the name of your framework
1738
import type { Meta, StoryObj } from '@storybook/your-framework';
1839

1940
import { MyComponent } from './MyComponent';
2041

21-
const meta: Meta<typeof MyComponent> = {
42+
const meta = {
2243
component: MyComponent,
23-
tags: ['test-only'], // 👈 Provides the `test-only` tag to all stories in this file
24-
};
44+
//👇 Provides the `test-only` tag to all stories in this file
45+
tags: ['test-only'],
46+
} satisfies Meta<typeof MyComponent>;
2547

2648
export default meta;
27-
type Story = StoryObj<typeof MyComponent>;
49+
type Story = StoryObj<typeof meta>;
2850

2951
export const IncludeStory: Story = {
3052
//👇 Adds the `test-only` tag to this story to be included in the tests when enabled in the test-runner configuration

docs/_snippets/my-component-skip-tags.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js" tabTitle="story"
1+
```ts filename="MyComponent.stories.ts" renderer="angular" language="ts"
2+
import type { Meta, StoryObj } from '@storybook/angular';
3+
4+
import { MyComponent } from './MyComponent.component';
5+
6+
const meta: Meta<MyComponent> = {
7+
component: MyComponent,
8+
//👇 Provides the `skip-test` tag to all stories in this file
9+
tags: ['skip-test'],
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<MyComponent>;
14+
15+
export const SkipStory: Story = {
16+
//👇 Adds the `skip-test` tag to this story to allow it to be skipped in the tests when enabled in the test-runner configuration
17+
tags: ['skip-test'],
18+
};
19+
```
20+
21+
```js filename="MyComponent.stories.js|jsx" renderer="common" language="js"
222
import { MyComponent } from './MyComponent';
323

424
export default {
525
component: MyComponent,
6-
tags: ['skip-test'], // 👈 Provides the `skip-test` tag to all stories in this file
26+
//👇 Provides the `skip-test` tag to all stories in this file
27+
tags: ['skip-test'],
728
};
829

930
export const SkipStory = {
@@ -12,19 +33,20 @@ export const SkipStory = {
1233
};
1334
```
1435

15-
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts" tabTitle="story"
36+
```ts filename="MyComponent.stories.ts|tsx" renderer="common" language="ts"
1637
// Replace your-framework with the name of your framework
1738
import type { Meta, StoryObj } from '@storybook/your-framework';
1839

1940
import { MyComponent } from './MyComponent';
2041

21-
const meta: Meta<typeof MyComponent> = {
42+
const meta = {
2243
component: MyComponent,
23-
tags: ['skip-test'], // 👈 Provides the `skip-test` tag to all stories in this file
24-
};
44+
//👇 Provides the `skip-test` tag to all stories in this file
45+
tags: ['skip-test'],
46+
} satisfies Meta<typeof MyComponent>;
2547

2648
export default meta;
27-
type Story = StoryObj<typeof MyComponent>;
49+
type Story = StoryObj<typeof meta>;
2850

2951
export const SkipStory: Story = {
3052
//👇 Adds the `skip-test` tag to this story to allow it to be skipped in the tests when enabled in the test-runner configuration

docs/_snippets/play-function.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { RegistrationForm } from './RegistrationForm.component';
66
const meta: Meta<RegistrationForm> = {
77
component: RegistrationForm,
88
};
9-
export default meta;
109

10+
export default meta;
1111
type Story = StoryObj<RegistrationForm>;
1212

1313
/*
@@ -197,8 +197,8 @@ import RegistrationForm from './RegistrationForm.svelte';
197197
const meta = {
198198
component: RegistrationForm,
199199
} satisfies Meta<typeof RegistrationForm>;
200-
export default meta;
201200

201+
export default meta;
202202
type Story = StoryObj<typeof meta>;
203203

204204
/*
@@ -235,12 +235,12 @@ import type { Meta, StoryObj } from '@storybook/your-framework';
235235

236236
import { RegistrationForm } from './RegistrationForm';
237237

238-
const meta: Meta<typeof RegistrationForm> = {
238+
const meta = {
239239
component: RegistrationForm,
240-
};
241-
export default meta;
240+
} satisfies Meta<typeof RegistrationForm>;
242241

243-
type Story = StoryObj<typeof RegistrationForm>;
242+
export default meta;
243+
type Story = StoryObj<typeof meta>;
244244

245245
/*
246246
* See https://storybook.js.org/docs/writing-stories/play-function#working-with-the-canvas
@@ -309,8 +309,8 @@ import type { Meta, StoryObj } from '@storybook/web-components-vite';
309309
const meta: Meta = {
310310
component: 'demo-registration-form',
311311
};
312-
export default meta;
313312

313+
export default meta;
314314
type Story = StoryObj;
315315

316316
/*

0 commit comments

Comments
 (0)