Skip to content

Commit

Permalink
Implement utils as separate @muban/testing-library package
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaNarie committed Jan 11, 2022
1 parent c054255 commit e3c8e12
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 139 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Run `npm run storybook` to preview your stories and documentation.
* `useHookName.stories.ts` – To showcase the hook with a working UI, also used for dom testing
* `useHookName.stories.mdx` – Documentation about the hook
* `useHookName.test.ts` – Unit tests for the hook
* `useHookNameStories.test.ts` – Unit tests for the stories using `testing-library`
* `useHookNameStories.test.ts` – Unit tests for the stories using `@muban/testing-library`

### Steps for adding a new Hook:

Expand Down Expand Up @@ -141,8 +141,8 @@ if intermediate state requires testing.

## Writing Story tests

Use the `render` function to render a Story component in the DOM, and use the "testing-library"
query, event and assert functions to test if your Story works as intended.
Use the `render` function to render a Story component in the DOM, and use the
"@muban/testing-library" query, event and assert functions to test if your Story works as intended.

Add `import '@testing-library/jest-dom';` to the top of your file to augment Jest with
additional matchers for DOM elements.
Expand Down
41 changes: 32 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
"@babel/runtime-corejs3": "^7.12.5",
"@muban/eslint-config": "^1.0.0-alpha.4",
"@muban/muban": "^1.0.0-alpha.28",
"@muban/storybook": "^7.0.0-alpha.18",
"@muban/storybook": "^7.0.0-alpha.19",
"@muban/template": "^1.0.0-alpha.1",
"@muban/test-mock": "npm:@muban/muban@^1.0.0-alpha.28",
"@muban/testing-library": "^1.0.0-alpha.3",
"@storybook/addon-actions": "^6.4.9",
"@storybook/addon-essentials": "^6.4.9",
"@storybook/addon-links": "^6.4.9",
Expand Down
32 changes: 0 additions & 32 deletions src/testing-library/queryByRef.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/testing-library/readme.md

This file was deleted.

89 changes: 0 additions & 89 deletions src/testing-library/render.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/useEventListener/useEventListenerStories.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@testing-library/jest-dom';
import { waitFor } from '@testing-library/dom';
import { render } from '../testing-library/render';
import { waitFor, render } from '@muban/testing-library';
import { Demo } from './useEventListener.stories';

describe('useEventListener stories', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/useToggle/useToggleStories.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@testing-library/jest-dom';
import { waitFor } from '@testing-library/dom';
import { render } from '../testing-library/render';
import { waitFor, render } from '@muban/testing-library';
import { Demo } from './useToggle.stories';

describe('useToggle stories', () => {
Expand Down

0 comments on commit e3c8e12

Please sign in to comment.