Skip to content

Commit

Permalink
Merge pull request #15594 from doutori/feature/add-unittest-snipet-fo…
Browse files Browse the repository at this point in the history
…r-preact

[Documentation] Add an unit test snipet for preact
  • Loading branch information
jonniebigodes authored Jul 15, 2021
2 parents 2efd8b1 + 58a660a commit 6ddfbc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/snippets/preact/button-test.js.mdx
Original file line number Diff line number Diff line change
@@ -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(<Primary {...Primary.args} />);
expect(screen.getByRole('button')).toHaveTextContent('Primary');
});
```
1 change: 1 addition & 0 deletions docs/workflows/unit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Here is an example of how you can use it in a testing library:
<CodeSnippets
paths={[
'react/button-test.js.mdx',
'preact/button-test.js.mdx',
'vue/button-test.js.mdx',
'angular/button-test.ts.mdx',
'svelte/button-test.js.mdx',
Expand Down

0 comments on commit 6ddfbc3

Please sign in to comment.