docs/_snippets/after-each-in-meta.md
import type { Meta, StoryObj } from '@storybook/angular';
import { Page } from './page.component';
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 Basic: Story = {
async play({ canvas }) {
// ...
},
};
import preview from '../.storybook/preview';
import { Page } from './page.component';
const meta = preview.meta({
component: Page,
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import Page from './Page.svelte';
const { Story } = 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 }) => {
// ...
}}
/>
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 Basic = {
async play({ canvas }) {
// ...
},
};
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 Basic = {
async play({ canvas }) {
// ...
},
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import Page from './Page.svelte';
const { Story } = 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 }) => {
// ...
}}
/>
// 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 Basic: Story = {
async play({ canvas }) {
// ...
},
};
// 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 Basic: Story = {
async play({ canvas }) {
// ...
},
};
export default {
component: 'my-page',
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
};
export const Basic = {
async play({ canvas }) {
// ...
},
};
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 Basic: Story = {
async play({ canvas }) {
// ...
},
};
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'my-page',
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'my-page',
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
import preview from '../.storybook/preview';
import { Page } from './Page';
const meta = preview.meta({
component: Page,
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
import preview from '../.storybook/preview';
import { Page } from './Page';
const meta = preview.meta({
component: Page,
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
import preview from '../.storybook/preview';
import Page from './Page.vue';
const meta = preview.meta({
component: Page,
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});
import preview from '../.storybook/preview';
import Page from './Page.vue';
const meta = preview.meta({
component: Page,
// ๐ Runs after each story in this file
async afterEach(context) {
console.log(`โ
Tested ${context.name} story`);
},
});
export const Basic = meta.story({
async play({ canvas }) {
// ...
},
});