diff --git a/docs/snippets/preact/button-test.js.mdx b/docs/snippets/preact/button-test.js.mdx new file mode 100644 index 000000000000..2c1889942549 --- /dev/null +++ b/docs/snippets/preact/button-test.js.mdx @@ -0,0 +1,17 @@ +```js +// Button.test.js + +import { h } from 'preact'; + +import { render, screen } from '@testing-library/preact'; + +import '@testing-library/jest-dom/extend-expect'; + +//👇 Imports a specific story for the test +import { Primary } from './Button.stories'; + +it('renders the button in the primary state', () => { + render(); + expect(screen.getByRole('button')).toHaveTextContent('Primary'); +}); +``` diff --git a/docs/workflows/unit-testing.md b/docs/workflows/unit-testing.md index 8fa58c09b8da..15624c092528 100644 --- a/docs/workflows/unit-testing.md +++ b/docs/workflows/unit-testing.md @@ -15,6 +15,7 @@ Here is an example of how you can use it in a testing library: