@@ -72,7 +72,7 @@ Open the extension manager with <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>X</kbd> (W
72
72
73
73
## Cheat Sheet
74
74
75
- You can write any combination of Search variants and Search types.
75
+ You can write any combination of ** Search variants** and ** Search types** .
76
76
77
77
### Search variants
78
78
@@ -89,16 +89,16 @@ You can write any combination of Search variants and Search types.
89
89
90
90
Sorted by oficial recommended [ order of priority] ( https://testing-library.com/docs/queries/about/#priority ) .
91
91
92
- | | Types | finds by... | DOM example |
93
- | - | --------------------- | -------------------------------- | ------------------------------------- |
94
- | 1 | ..., ` Role ` | [ ARIA role] ( https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles ) | ` <div role="dialog" /> ` |
95
- | 2 | ..., ` LabelText ` | label or aria-label content | ` <label for="element" /> ` |
96
- | 3 | ..., ` PlaceholderText ` | input placeholder value | ` <input placeholder="name" /> ` |
97
- | 4 | ..., ` Text ` | element text content | ` <p>Lorem ipsum</p> ` |
98
- | 5 | ..., ` DisplayValue ` | form element current value | ` <input value="Current Value"> ` |
99
- | 6 | ..., ` AltText ` | img alt attribute | ` <img alt="movie poster" /> ` |
100
- | 7 | ..., ` Title ` | title attribute or svg title tag | ` <span title="Add" /> ` or ` <title /> ` |
101
- | 8 | ..., ` TestId ` | data-testid attribute | ` <div data-testid="some-message" /> ` |
92
+ | | Types | finds by... | DOM example |
93
+ | - | -------------------- | -------------------------------- | ------------------------------------- |
94
+ | 1 | ...` Role ` | [ ARIA role] ( https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles ) | ` <div role="dialog" /> ` |
95
+ | 2 | ...` LabelText ` | label or aria-label content | ` <label for="element" /> ` |
96
+ | 3 | ...` PlaceholderText ` | input placeholder value | ` <input placeholder="name" /> ` |
97
+ | 4 | ...` Text ` | element text content | ` <p>Lorem ipsum</p> ` |
98
+ | 5 | ...` DisplayValue ` | form element current value | ` <input value="Current Value"> ` |
99
+ | 6 | ...` AltText ` | img alt attribute | ` <img alt="movie poster" /> ` |
100
+ | 7 | ...` Title ` | title attribute or svg title tag | ` <span title="Add" /> ` or ` <title /> ` |
101
+ | 8 | ...` TestId ` | data-testid attribute | ` <div data-testid="some-message" /> ` |
102
102
103
103
> For more information visit the oficial cheat sheet: [ DOM] ( https://testing-library.com/docs/dom-testing-library/cheatsheet ) - [ React] ( https://testing-library.com/docs/react-testing-library/cheatsheet ) - [ Vue] ( https://testing-library.com/docs/vue-testing-library/cheatsheet )
104
104
@@ -128,31 +128,33 @@ Below is a list of all available snippets and the triggers of each one. The `░
128
128
129
129
### Queries
130
130
131
+ All the query ` ░variant ` start with ` ░getBy ` by default, but can be easily changed between ` <getBy|getAllBy|queryBy|queryAllBy|findBy|findByAll> ` once reach the TAB position.
132
+
131
133
#### 1. Role
132
134
133
135
| Trigger | Result |
134
136
| :------- | ----------------------------------------------------------------- |
135
- | ` br→ ` | ` screen.░getByRole ('░id')█ ` |
136
- | ` bro→ ` | ` screen.░getByRole ('░id', {░})█ ` |
137
- | ` bron→ ` | ` screen.░getByRole ('░id', {name: ░})█ ` |
138
- | ` brc→ ` | ` screen.░getByRole ('checkbox')█ ` |
139
- | ` brcc→ ` | ` screen.░getByRole ('checkbox', { checked: ░<true\|false>} })█ ` |
140
- | ` brh→ ` | ` screen.░getByRole ('heading')█ ` |
141
- | ` brhl→ ` | ` screen.░getByRole ('heading', { level: ░<1\|2\|3\|4\|5\|6>} })█ ` |
137
+ | ` br→ ` | ` screen.░variantRole ('░id')█ ` |
138
+ | ` bro→ ` | ` screen.░variantRole ('░id', {░})█ ` |
139
+ | ` bron→ ` | ` screen.░variantRole ('░id', {name: ░})█ ` |
140
+ | ` brc→ ` | ` screen.░variantRole ('checkbox')█ ` |
141
+ | ` brcc→ ` | ` screen.░variantRole ('checkbox', { checked: ░<true\|false>} })█ ` |
142
+ | ` brh→ ` | ` screen.░variantRole ('heading')█ ` |
143
+ | ` brhl→ ` | ` screen.░variantRole ('heading', { level: ░<1\|2\|3\|4\|5\|6>} })█ ` |
142
144
143
145
#### 4. Text
144
146
145
147
| Trigger | Result |
146
148
| :------- | ----------------------------------------------------------------- |
147
- | ` bt→ ` | ` screen.░getByText (░)█ ` |
148
- | ` btf→ ` | ` screen.░getByText ('░Text Match')█ ` |
149
- | ` bti→ ` | ` screen.░getByText ('░text match', {ignore: false})█ ` |
150
- | ` bts→ ` | ` screen.░getByText ('░ext Matc', {exact: false})█ ` |
151
- | ` btsi→ ` | ` screen.░getByText ('░ext matc', {exact: false, ignore: false})█ ` |
152
- | ` btsw→ ` | ` screen.░getByText ((content) => content.startsWith('░Text'))█ ` |
153
- | ` btesw→ ` | <code >screen.░getByText ((content, element) => {<br />  ;  ; const tag = element.tagName.toLowerCase() === '░div'<br />  ;  ; return tag && content.startsWith('░Text')<br />})█</code > |
154
- | ` btew→ ` | ` screen.░getByText ((content) => content.endsWith('░Match'))█ ` |
155
- | ` bteew→ ` | <code >screen.░getByText ((content, element) => {<br />  ;  ; const tag = element.tagName.toLowerCase() === '░div'<br />  ;  ; return tag && content.endsWith('░Match')<br />})█</code > |
149
+ | ` bt→ ` | ` screen.░variantText (░)█ ` |
150
+ | ` btf→ ` | ` screen.░variantText ('░Text Match')█ ` |
151
+ | ` bti→ ` | ` screen.░variantText ('░text match', {ignore: false})█ ` |
152
+ | ` bts→ ` | ` screen.░variantText ('░ext Matc', {exact: false})█ ` |
153
+ | ` btsi→ ` | ` screen.░variantText ('░ext matc', {exact: false, ignore: false})█ ` |
154
+ | ` btsw→ ` | ` screen.░variantText ((content) => content.startsWith('░Text'))█ ` |
155
+ | ` btesw→ ` | <code >screen.░variantText ((content, element) => {<br />  ;  ; const tag = element.tagName.toLowerCase() === '░div'<br />  ;  ; return tag && content.startsWith('░Text')<br />})█</code > |
156
+ | ` btew→ ` | ` screen.░variantText ((content) => content.endsWith('░Match'))█ ` |
157
+ | ` bteew→ ` | <code >screen.░variantText ((content, element) => {<br />  ;  ; const tag = element.tagName.toLowerCase() === '░div'<br />  ;  ; return tag && content.endsWith('░Match')<br />})█</code > |
156
158
157
159
### Debug
158
160
0 commit comments