7
7
8
8
<p >Simple and complete custom Cypress commands and utilities that encourage good testing practices.</p >
9
9
10
- [ ** Read the docs** ] ( https://testing-library.com/cypress ) | [ Edit the docs] ( https://github.com/alexkrolick/testing-library-docs )
10
+ [ ** Read the docs** ] ( https://testing-library.com/cypress ) |
11
+ [ Edit the docs] ( https://github.com/alexkrolick/testing-library-docs )
11
12
12
13
</div >
13
14
14
15
<hr />
15
16
16
17
[ ![ Build Status] [ build-badge ]] [ build ]
17
18
[ ![ Code Coverage] [ coverage-badge ]] [ coverage ]
18
- [ ![ version] [ version-badge ]] [ package ]
19
- [ ![ downloads] [ downloads-badge ]] [ npmtrends ]
19
+ [ ![ version] [ version-badge ]] [ package ] [ ![ downloads] [ downloads-badge ]] [ npmtrends ]
20
20
[ ![ MIT License] [ license-badge ]] [ license ]
21
21
22
22
[ ![ All Contributors] ( https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square )] ( #contributors )
23
- [ ![ PRs Welcome] [ prs-badge ]] [ prs ]
24
- [ ![ Code of Conduct] [ coc-badge ]] [ coc ]
23
+ [ ![ PRs Welcome] [ prs-badge ]] [ prs ] [ ![ Code of Conduct] [ coc-badge ]] [ coc ]
25
24
26
25
[ ![ Watch on GitHub] [ github-watch-badge ]] [ github-watch ]
27
26
[ ![ Star on GitHub] [ github-star-badge ]] [ github-star ]
35
34
36
35
## The problem
37
36
38
- You want to use [ ` dom-testing-library ` ] [ dom-testing-library ] methods in your [ Cypress] [ cypress ] tests.
37
+ You want to use [ ` dom-testing-library ` ] [ dom-testing-library ] methods in your
38
+ [ Cypress] [ cypress ] tests.
39
39
40
40
## This solution
41
41
42
- This allows you to use all the useful [ ` dom-testing-library ` ] [ dom-testing-library ] methods in your tests.
42
+ This allows you to use all the useful
43
+ [ ` dom-testing-library ` ] [ dom-testing-library ] methods in your tests.
43
44
44
45
## Table of Contents
45
46
@@ -66,7 +67,8 @@ npm install --save-dev cypress-testing-library
66
67
67
68
### With typescript
68
69
69
- Typings are defined under ` cypress-testing-library/typings ` , and should be added as follows in ` tsconfig.json ` :
70
+ Typings are defined under ` cypress-testing-library/typings ` , and should be added
71
+ as follows in ` tsconfig.json ` :
70
72
71
73
``` json
72
74
{
@@ -86,9 +88,12 @@ Add this line to your project's `cypress/support/commands.js`:
86
88
import 'cypress-testing-library/add-commands';
87
89
```
88
90
89
- You can now use all of ` dom-testing-library ` 's ` getBy ` , ` getAllBy ` , ` queryBy ` and ` queryAllBy ` commands. [ See ` dom-testing-library ` repo for reference] ( https://github.com/kentcdodds/dom-testing-library#usage )
91
+ You can now use all of ` dom-testing-library ` 's ` getBy ` , ` getAllBy ` , ` queryBy `
92
+ and ` queryAllBy ` commands.
93
+ [ See ` dom-testing-library ` repo for reference] ( https://github.com/kentcdodds/dom-testing-library#usage )
90
94
91
- To show some simple examples (from [ cypress/integration/commands.spec.js] ( cypress/integration/commands.spec.js ) ):
95
+ To show some simple examples (from
96
+ [ cypress/integration/commands.spec.js] ( cypress/integration/commands.spec.js ) ):
92
97
93
98
``` javascript
94
99
cy .getAllByText (' Jackie Chan' ).click ()
@@ -103,7 +108,11 @@ cy.get('form').then(subject => {
103
108
})
104
109
```
105
110
106
- ` cypress-testing-library ` supports both jQuery elements and DOM nodes. This is necessary because Cypress uses jQuery elements, while ` dom-testing-library ` expects DOM nodes. When you pass a jQuery element as ` container ` , it will get the first DOM node from the collection and use that as the ` container ` parameter for the ` dom-testing-library ` functions.
111
+ ` cypress-testing-library ` supports both jQuery elements and DOM nodes. This is
112
+ necessary because Cypress uses jQuery elements, while ` dom-testing-library `
113
+ expects DOM nodes. When you pass a jQuery element as ` container ` , it will get
114
+ the first DOM node from the collection and use that as the ` container ` parameter
115
+ for the ` dom-testing-library ` functions.
107
116
108
117
## Other Solutions
109
118
@@ -131,27 +140,41 @@ MIT
131
140
132
141
[ npm ] : https://www.npmjs.com/
133
142
[ node ] : https://nodejs.org
134
- [ build-badge ] : https://img.shields.io/travis/kentcdodds/cypress-testing-library.svg?style=flat-square
143
+ [ build-badge] :
144
+ https://img.shields.io/travis/kentcdodds/cypress-testing-library.svg?style=flat-square
135
145
[ build ] : https://travis-ci.org/kentcdodds/cypress-testing-library
136
- [ coverage-badge ] : https://img.shields.io/codecov/c/github/kentcdodds/cypress-testing-library.svg?style=flat-square
146
+ [ coverage-badge] :
147
+ https://img.shields.io/codecov/c/github/kentcdodds/cypress-testing-library.svg?style=flat-square
137
148
[ coverage ] : https://codecov.io/github/kentcdodds/cypress-testing-library
138
- [ version-badge ] : https://img.shields.io/npm/v/cypress-testing-library.svg?style=flat-square
149
+ [ version-badge] :
150
+ https://img.shields.io/npm/v/cypress-testing-library.svg?style=flat-square
139
151
[ package ] : https://www.npmjs.com/package/cypress-testing-library
140
- [ downloads-badge ] : https://img.shields.io/npm/dm/cypress-testing-library.svg?style=flat-square
152
+ [ downloads-badge] :
153
+ https://img.shields.io/npm/dm/cypress-testing-library.svg?style=flat-square
141
154
[ npmtrends ] : http://www.npmtrends.com/cypress-testing-library
142
- [ license-badge ] : https://img.shields.io/npm/l/cypress-testing-library.svg?style=flat-square
143
- [ license ] : https://github.com/kentcdodds/cypress-testing-library/blob/master/LICENSE
144
- [ prs-badge ] : https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
155
+ [ license-badge] :
156
+ https://img.shields.io/npm/l/cypress-testing-library.svg?style=flat-square
157
+ [ license] :
158
+ https://github.com/kentcdodds/cypress-testing-library/blob/master/LICENSE
159
+ [ prs-badge] :
160
+ https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
145
161
[ prs ] : http://makeapullrequest.com
146
- [ donate-badge ] : https://img.shields.io/badge/$-support-green.svg?style=flat-square
147
- [ coc-badge ] : https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
148
- [ coc ] : https://github.com/kentcdodds/cypress-testing-library/blob/master/other/CODE_OF_CONDUCT.md
149
- [ github-watch-badge ] : https://img.shields.io/github/watchers/kentcdodds/cypress-testing-library.svg?style=social
162
+ [ donate-badge] :
163
+ https://img.shields.io/badge/$-support-green.svg?style=flat-square
164
+ [ coc-badge] :
165
+ https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
166
+ [ coc] :
167
+ https://github.com/kentcdodds/cypress-testing-library/blob/master/other/CODE_OF_CONDUCT.md
168
+ [ github-watch-badge] :
169
+ https://img.shields.io/github/watchers/kentcdodds/cypress-testing-library.svg?style=social
150
170
[ github-watch ] : https://github.com/kentcdodds/cypress-testing-library/watchers
151
- [ github-star-badge ] : https://img.shields.io/github/stars/kentcdodds/cypress-testing-library.svg?style=social
171
+ [ github-star-badge] :
172
+ https://img.shields.io/github/stars/kentcdodds/cypress-testing-library.svg?style=social
152
173
[ github-star ] : https://github.com/kentcdodds/cypress-testing-library/stargazers
153
- [ twitter ] : https://twitter.com/intent/tweet?text=Check%20out%20cypress-testing-library%20by%20%40kentcdodds%20https%3A%2F%2Fgithub.com%2Fkentcdodds%2Fcypress-testing-library%20%F0%9F%91%8D
154
- [ twitter-badge ] : https://img.shields.io/twitter/url/https/github.com/kentcdodds/cypress-testing-library.svg?style=social
174
+ [ twitter] :
175
+ https://twitter.com/intent/tweet?text=Check%20out%20cypress-testing-library%20by%20%40kentcdodds%20https%3A%2F%2Fgithub.com%2Fkentcdodds%2Fcypress-testing-library%20%F0%9F%91%8D
176
+ [ twitter-badge] :
177
+ https://img.shields.io/twitter/url/https/github.com/kentcdodds/cypress-testing-library.svg?style=social
155
178
[ emojis ] : https://github.com/kentcdodds/all-contributors#emoji-key
156
179
[ all-contributors ] : https://github.com/kentcdodds/all-contributors
157
180
[ dom-testing-library ] : https://github.com/kentcdodds/dom-testing-library
0 commit comments