Skip to content

Commit 98c8cb4

Browse files
authored
Update README.md
1 parent 3e636ad commit 98c8cb4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ npm install --save-dev jsdom-testing-mocks
1111
Mocks `matchMedia`, allows testing of component's behavior depending on the viewport description (supports all of the [Media Features](http://www.w3.org/TR/css3-mediaqueries/#media1)). `mockViewport` must be called before rendering the component
1212

1313
Example, using `React Testing Library`:
14-
1514
```jsx
1615
import { mockViewport } from 'jsdom-testing-mocks"
1716
@@ -34,6 +33,23 @@ it('shows the right lines on desktop and mobile', () => {
3433
})
3534
```
3635
36+
Also, you can mock the viewport for a group of tests, using `mockViewportForTestGroup`:
37+
```jsx
38+
import { mockViewportForTestGroup } from 'jsdom-testing-mocks"
39+
40+
describe('Desktop specific tests', () => {
41+
mockViewportForTestGroup({ width: '1440px', height: '900px' })
42+
43+
test('this', () = {
44+
// ...
45+
})
46+
47+
test('that', () = {
48+
// ...
49+
})
50+
})
51+
```
52+
3753
## Mock intersection observer
3854
Provides a way of triggering intersection observer events
3955

0 commit comments

Comments
 (0)