mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 21:21:47 +08:00
19 lines
503 B
Plaintext
19 lines
503 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('renders and executes the play function', async () => {
|
|
const PrimaryStory = composeStory(Primary, meta);
|
|
|
|
// First, render the story
|
|
const { container } = render(<PrimaryStory />);
|
|
|
|
// Then, execute the play function
|
|
await PrimaryStory.play({ canvasElement: container });
|
|
});
|
|
```
|