File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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 },
You can’t perform that action at this time.
0 commit comments