storybook/docs/snippets/react/portable-stories-vitest-with-loaders.ts.mdx
2024-02-27 11:17:53 -07:00

19 lines
448 B
Plaintext

```tsx
// Button.test.tsx
import { test } from 'vitest';
import { render } from '@testing-library/react';
import { composeStory } from '@storybook/react';
import meta, { Primary } from './Button.stories';
test('applies the loaders and renders', async () => {
const PrimaryStory = composeStory(Primary, meta);
// First, load the data for the story
await PrimaryStory.load();
// Then, render the story
render(<PrimaryStory />);
});
```