Skip to content

Commit 776e84b

Browse files
Jasmine dom docs (#572)
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 7a2db2b commit 776e84b

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/ecosystem-jasmine-dom.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
id: ecosystem-jasmine-dom
3+
title: jasmine-dom
4+
---
5+
6+
[`jasmine-dom`][gh] is a companion library for Testing Library that
7+
provides custom DOM element matchers for Jasmine
8+
9+
```
10+
npm install --save-dev @testing-library/jasmine-dom
11+
```
12+
13+
Then follow [usage section][gh-usage] from jasmine-dom's documentation to add
14+
the matchers to Jasmine.
15+
16+
```jsx
17+
<span data-testid="not-empty"><span data-testid="empty"></span></span>
18+
<div data-testid="visible">Visible Example</div>
19+
20+
expect(screen.queryByTestId('not-empty')).not.toBeEmptyDOMElement()
21+
expect(screen.getByText('Visible Example')).toBeVisible()
22+
```
23+
24+
> Note: when using some of these matchers, you may need to make sure you use a
25+
> query function (like `queryByTestId`) rather than a get function (like
26+
> `getByTestId`). Otherwise the `get*` function could throw an error before your
27+
> assertion.
28+
29+
Check out [jasmine-dom's documentation][gh] for a full list of available
30+
matchers.
31+
32+
- [jasmine-dom on GitHub][gh]
33+
34+
[gh]: https://github.com/testing-library/jasmine-dom
35+
[gh-usage]: https://github.com/testing-library/jasmine-dom#usage

docs/ecosystem-jest-dom.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ matchers to Jest.
1717
<span data-testid="not-empty"><span data-testid="empty"></span></span>
1818
<div data-testid="visible">Visible Example</div>
1919

20-
expect(queryByTestId(container, 'not-empty')).not.toBeEmpty()
21-
expect(getByText(container, 'Visible Example')).toBeVisible()
20+
expect(screen.queryByTestId('not-empty')).not.toBeEmptyDOMElement()
21+
expect(screen.getByText('Visible Example')).toBeVisible()
2222
```
2323

2424
> Note: when using some of these matchers, you may need to make sure you use a

website/sidebars.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@
112112
"ecosystem-react-select-event",
113113
"ecosystem-eslint-plugin-testing-library",
114114
"ecosystem-eslint-plugin-jest-dom",
115-
"ecosystem-riot-testing-library"
115+
"ecosystem-riot-testing-library",
116+
"ecosystem-jasmine-dom"
116117
],
117118
"Help": ["faq", "learning", "contributing"]
118119
},

0 commit comments

Comments
 (0)