riot-testing-library
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "riot-testing-library", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Simple and complete Riot testing utilities that encourage good testing practices.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,3 @@ # riot-testing-library | ||
[](https://codecov.io/gh/ariesjia/riot-testing-library) | ||
[](https://codeclimate.com/github/ariesjia/riot-testing-library/maintainability) | ||
@@ -33,9 +34,6 @@ ## API | ||
Unmounts the component from the container and destroys the container. | ||
`cleanup()` is called after each test automatically by default if the testing framework you're using supports the afterEach global (like mocha, Jest, and Jasmine). | ||
However, you may choose to skip the auto cleanup by setting the RIOT_TL_SKIP_AUTO_CLEANUP env variable to 'true'. | ||
To make this even easier, you can also simply import `riot-testing-library/dont-cleanup-after-each` which will do the same thing. | ||
```javascript | ||
afterEach(() => { | ||
cleanup() | ||
}) | ||
``` | ||
### also export all api from [@testing-library/dom](https://testing-library.com/docs/dom-testing-library/intro) | ||
@@ -46,3 +44,3 @@ | ||
### Component | ||
```riotjs | ||
```html | ||
<app> | ||
@@ -68,9 +66,5 @@ <p data-testid="count">{ state.count }</p> | ||
```javascript | ||
import render, { cleanup, fireEvent } from 'riot-testing-library' | ||
import render, { fireEvent } from 'riot-testing-library' | ||
import TestTag from './test.tag' | ||
afterEach(() => { | ||
cleanup() | ||
}) | ||
test('should show count text when rendered', () => { | ||
@@ -81,3 +75,3 @@ const { queryByTestId } = render(TestTag, {count: 10}); | ||
test('should add count when click add button text', async () => { | ||
test('should add count when click add button text', () => { | ||
const { queryByTestId } = render(TestTag, {count: 1}); | ||
@@ -84,0 +78,0 @@ expect(queryByTestId('count').textContent).toBe("1"); |
7251
7
46
78