storybook/docs/snippets/react/portable-stories-cypress-ct-async.ts.mdx
2024-02-27 11:09:30 -07:00

27 lines
653 B
Plaintext

```tsx
// Button.test.tsx
import { composeStories } from '@storybook/react';
import * as stories from './Button.stories';
const { CSF3Primary } = composeStories(stories);
describe('<Button />', () => {
it('renders with loaders and play function', () => {
cy.then(async () => {
await CSF3Primary.load();
});
cy.mount(<CSF3Primary />);
cy.then(async () => {
await CSF3Primary.play({
// data-cy-root is Cypress "App". The top-most wrapping element
canvasElement: document.querySelector('[data-cy-root]'),
});
// Cypress assertions happen inside of this scope, after play
});
});
});
```