Skip to content

Commit

Permalink
Add an unit test snipet of preact
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroaki Sasaki committed Jul 15, 2021
1 parent 6846b64 commit 58a660a
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 58a660a

Please sign in to comment.