Skip to content

Commit 02dddb0

Browse files
authored
Merge pull request #15 from deinsoftware/dev
add query types
2 parents 5c374c3 + a19270b commit 02dddb0

File tree

6 files changed

+163
-2
lines changed

6 files changed

+163
-2
lines changed

Diff for: .github/examples/variant-snippets.gif

1.24 MB
Loading

Diff for: .vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"qtew",
2121
"qtf",
2222
"qti",
23+
"qtif",
24+
"qtis",
2325
"qts",
2426
"qtsi",
2527
"qtsw",

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Fixed for any bug fixes.
99
Security to invite users to upgrade in case of vulnerabilities.
1010
-->
1111

12+
## 1.0.0 - 2023/04/21
13+
14+
### Added
15+
16+
- PlaceholderText, DisplayValue, AltText, Title, TestId queries snippets
17+
- Visual example about how you can use the query variants
18+
1219
## 0.0.3 - 2023/04/18
1320

1421
### Added

Diff for: README.md

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Testing Library Snippets (WIP)
1+
# Testing Library Snippets
22

33
[![Version](https://img.shields.io/visual-studio-marketplace/v/deinsoftware.testing-library-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=deinsoftware.testing-library-snippets)
44
[![Installs](https://img.shields.io/visual-studio-marketplace/i/deinsoftware.testing-library-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=deinsoftware.testing-library-snippets)
@@ -142,6 +142,8 @@ Below is a list of all available snippets and the triggers of each one. The `░
142142

143143
All the `░variantBy` cursor start with `getBy` by default, but can be easily changed between `<getBy|getAllBy|queryBy|queryAllBy|findBy|findByAll>` using arrow keys once reach the TAB position.
144144

145+
![Variant Snippets Example](https://raw.githubusercontent.com/deinsoftware/vscode-testing-library-snippets/main/.github/examples/variant-snippets.gif)
146+
145147
#### 1. Role
146148

147149
| Trigger | Result |
@@ -178,6 +180,46 @@ All the `░variantBy` cursor start with `getBy` by default, but can be easily c
178180
| `qtew→` | `screen.░variantByText((content) => content.endsWith('░Match'))█` |
179181
| `qteew→` | <code>screen.░variantByText((content, element) => {<br/>&nbsp;&nbsp;const tag = element.tagName.toLowerCase() === '░div'<br/>&nbsp;&nbsp;return tag && content.endsWith('░Match')<br/>})█</code> |
180182

183+
#### 5. PlaceholderText
184+
185+
| Trigger | Result |
186+
| :------- | ----------------------------------------------------------------- |
187+
| `qp→` | `screen.░variantByPlaceholderText(░)█` |
188+
| `qpf→` | `screen.░variantByPlaceholderText('░Text Match')█` |
189+
| `qps→` | `screen.░variantByPlaceholderText('░ext Matc', {exact: false})█` |
190+
191+
#### 6. DisplayValue
192+
193+
| Trigger | Result |
194+
| :------- | -------------------------------------------------------------- |
195+
| `qd→` | `screen.░variantByDisplayValue(░)█` |
196+
| `qdf→` | `screen.░variantByDisplayValue('░Text Match')█` |
197+
| `qds→` | `screen.░variantByDisplayValue('░ext Matc', {exact: false})█` |
198+
199+
#### 7. AltText
200+
201+
| Trigger | Result |
202+
| :------- | --------------------------------------------------------- |
203+
| `qa→` | `screen.░variantByAltText(░)█` |
204+
| `qaf→` | `screen.░variantByAltText('░Text Match')█` |
205+
| `qas→` | `screen.░variantByAltText('░ext Matc', {exact: false})█` |
206+
207+
#### 8. Title
208+
209+
| Trigger | Result |
210+
| :------- | ------------------------------------------------------- |
211+
| `qt→` | `screen.░variantByTitle(░)█` |
212+
| `qtf→` | `screen.░variantByTitle('░Text Match')█` |
213+
| `qts→` | `screen.░variantByTitle('░ext Matc', {exact: false})█` |
214+
215+
#### 9. TestId
216+
217+
| Trigger | Result |
218+
| :------- | -------------------------------------------------------- |
219+
| `qti→` | `screen.░variantByTestId(░)█` |
220+
| `qtif→` | `screen.░variantByTestId('░Text Match')█` |
221+
| `qtis→` | `screen.░variantByTestId('░ext Matc', {exact: false})█` |
222+
181223
### Debug
182224

183225
| Trigger | Result |

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "testing-library-snippets",
33
"description": "VS Code Testing Library snippets for JS and TS",
4-
"version": "0.3.0",
4+
"version": "1.0.0",
55
"displayName": "Testing Library Snippets",
66
"publisher": "deinsoftware",
77
"icon": "images/light-icon.png",

Diff for: snippets/queries.json

+110
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,115 @@
153153
"})"
154154
],
155155
"description": "Text query end with match on specific element"
156+
},
157+
158+
"query.placeholder": {
159+
"prefix": "qp",
160+
"body": [
161+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}PlaceholderText($2)$0"
162+
],
163+
"description": "PlaceholderText query"
164+
},
165+
"query.placeholder.full": {
166+
"prefix": "qpf",
167+
"body": [
168+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}PlaceholderText('${2:Text Match}')$0"
169+
],
170+
"description": "PlaceholderText query full string match"
171+
},
172+
"query.placeholder.substring": {
173+
"prefix": "qps",
174+
"body": [
175+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}PlaceholderText('${2:ext Matc}', {exact: false})$0"
176+
],
177+
"description": "PlaceholderText query substring match"
178+
},
179+
180+
"query.displayValue": {
181+
"prefix": "qd",
182+
"body": [
183+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}DisplayValue($2)$0"
184+
],
185+
"description": "DisplayValue query"
186+
},
187+
"query.displayValue.full": {
188+
"prefix": "qdf",
189+
"body": [
190+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}DisplayValue('${2:Text Match}')$0"
191+
],
192+
"description": "DisplayValue query full string match"
193+
},
194+
"query.displayValue.substring": {
195+
"prefix": "qds",
196+
"body": [
197+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}DisplayValue('${2:ext Matc}', {exact: false})$0"
198+
],
199+
"description": "DisplayValue query substring match"
200+
},
201+
202+
"query.altText": {
203+
"prefix": "qa",
204+
"body": [
205+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}AltText($2)$0"
206+
],
207+
"description": "AltText query"
208+
},
209+
"query.altText.full": {
210+
"prefix": "qaf",
211+
"body": [
212+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}AltText('${2:Text Match}')$0"
213+
],
214+
"description": "AltText query full string match"
215+
},
216+
"query.altText.substring": {
217+
"prefix": "qas",
218+
"body": [
219+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}AltText('${2:ext Matc}', {exact: false})$0"
220+
],
221+
"description": "AltText query substring match"
222+
},
223+
224+
"query.Title": {
225+
"prefix": "qt",
226+
"body": [
227+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}Title($2)$0"
228+
],
229+
"description": "Title query"
230+
},
231+
"query.Title.full": {
232+
"prefix": "qtf",
233+
"body": [
234+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}Title('${2:Text Match}')$0"
235+
],
236+
"description": "Title query full string match"
237+
},
238+
"query.Title.substring": {
239+
"prefix": "qts",
240+
"body": [
241+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}Title('${2:ext Matc}', {exact: false})$0"
242+
],
243+
"description": "Title query substring match"
244+
},
245+
246+
"query.TestId": {
247+
"prefix": "qti",
248+
"body": [
249+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}TestId($2)$0"
250+
],
251+
"description": "TestId query"
252+
},
253+
"query.TestId.full": {
254+
"prefix": "qtif",
255+
"body": [
256+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}TestId('${2:Text Match}')$0"
257+
],
258+
"description": "TestId query full string match"
259+
},
260+
"query.TestId.substring": {
261+
"prefix": "qtis",
262+
"body": [
263+
"screen.${1|getBy,getAllBy,queryBy,queryAllBy,findBy,findByAll|}TestId('${2:ext Matc}', {exact: false})$0"
264+
],
265+
"description": "TestId query substring match"
156266
}
157267
}

0 commit comments

Comments
 (0)