Skip to content

Commit 51cad6a

Browse files
authored
Merge pull request #5 from deinsoftware/dev
Dev
2 parents 7730a8a + 28200b9 commit 51cad6a

File tree

6 files changed

+203
-117
lines changed

6 files changed

+203
-117
lines changed

.vscode/settings.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
{
22
"cSpell.words": [
33
"beus",
4+
"brc",
5+
"brcc",
6+
"brh",
7+
"brhl",
8+
"bro",
9+
"bron",
10+
"bteew",
11+
"btesw",
12+
"btew",
13+
"btf",
14+
"bti",
15+
"bts",
16+
"btsi",
17+
"btsw",
418
"deinsoftware",
519
"Equiman",
6-
"gabr",
7-
"gabro",
8-
"gbrc",
9-
"gbrcc",
10-
"gbrh",
11-
"gbrhl",
12-
"gbro",
13-
"gbteew",
14-
"gbtesw",
15-
"gbtew",
16-
"gbtf",
17-
"gbti",
18-
"gbts",
19-
"gbtsi",
20-
"gbtsw",
21-
"github",
20+
"ithub",
2221
"itrh",
2322
"itue",
2423
"matc",
2524
"paypal",
2625
"rewi",
2726
"rswi",
2827
"sltp",
28+
"SWPM",
29+
"testid",
2930
"volta"
3031
],
3132
"markdownlint.config": {

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ Fixed for any bug fixes.
99
Security to invite users to upgrade in case of vulnerabilities.
1010
-->
1111

12+
## 0.0.6 - 2023/04/17
13+
14+
### Added
15+
16+
- cheat sheet helper section on README
17+
- wait for snippets
18+
19+
### Changed
20+
21+
- snippets with multiple search variants to avoid repetition
22+
1223
## 0.0.5 - 2023/04/16
1324

1425
### Added

README.md

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ The quick and easy way to create and use Testing Library with [VS Code](https://
1919
- [Extension Manager](#extension-manager)
2020
- [Marketplace](#marketplace)
2121
- [Supported Languages](#supported-languages)
22+
- [Cheat Sheet](#cheat-sheet)
2223
- [Snippets](#snippets)
2324
- [Import](#import)
2425
- [User Event](#user-event)
2526
- [Queries](#queries)
2627
- [Regex](#regex)
28+
- [Wait](#wait)
2729
- [Keyboard](#keyboard)
2830
- [Settings](#settings)
2931
- [About](#about)
@@ -68,6 +70,32 @@ Open the extension manager with <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>X</kbd> (W
6870

6971
---
7072

73+
## Cheat Sheet
74+
75+
| Search Variants | Result |
76+
| ---------------- | --------------------------------------------- |
77+
| `getBy`... | `Element` or `Error` |
78+
| `getAllBy`... | `Element[]` or `Error` |
79+
| `queryBy`... | `Element` or `null` |
80+
| `queryAllBy`... | `Element[]` or `null` |
81+
| `findBy`... | `Promise<Element>` or `Promise<rejection>` |
82+
| `findAllBy`... | `Promise<Element[]>` or `Promise<rejection>` |
83+
84+
| Search Types | Result |
85+
| --------------------- | --------------------------------------------- |
86+
| ...`Role` | `<div aria="role">` or [Aria Roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) |
87+
| ...`LabelText` | `<label for="Text">` |
88+
| ...`PlaceHolderText` | `<input placeholder="Text">` |
89+
| ...`Text` | `<a href="/page">Text</a>` |
90+
| ...`DisplayValue` | `<input value="Text">` |
91+
| ...`AltText` | `<img alt="Text">` |
92+
| ...`Title` | `<span title="Text">` or `<title>` |
93+
| ...`TestId` | `<input data-testid="Id">` |
94+
95+
[Back to menu](#menu)
96+
97+
---
98+
7199
## Snippets
72100

73101
Below is a list of all available snippets and the triggers of each one. The `` means the `TAB` jump position and `` the final cursor position.
@@ -90,48 +118,63 @@ Below is a list of all available snippets and the triggers of each one. The `░
90118

91119
### Queries
92120

93-
| Trigger | Result |
94-
| --------: | ---------------------------------------------------------------- |
95-
| `gbr→` | `screen.getByRole('░id')█` |
96-
| `gbro→` | `screen.getByRole('░id', {░})█` |
97-
| `gbrc→` | `screen.getByRole('checkbox')█` |
98-
| `gbrcc→` | `screen.getByRole('checkbox', { checked: ░<true\|false>} })█` |
99-
| `gbrh→` | `screen.getByRole('heading')█` |
100-
| `gbrhl→` | `screen.getByRole('heading', { level: ░<1\|2\|3\|4\|5\|6>} })█` |
101-
| `gabr→` | `screen.getAllByRole('░id')█` |
102-
| `gabro→` | `screen.getAllByRole('░id', {░})█` |
103-
| `gbt→` | `screen.getByText(░)█` |
104-
| `gbtf→` | `screen.getByText('░Text Match')█` |
105-
| `gbti→` | `screen.getByText('░text match', {ignore: false})█` |
106-
| `gbts→` | `screen.getByText('░ext Matc', {exact: false})█` |
107-
| `gbtsi→` | `screen.getByText('░ext matc', {exact: false, ignore: false})█` |
108-
| `gbtsw→` | `screen.getByText((content) => content.startsWith('░Text'))█` |
109-
| `gbtesw→` | <code>screen.getByText((content, element) => {<br/>&nbsp;&nbsp;return element.tagName.toLowerCase() === '░div' && content.startsWith('░Text')<br/>})█</code> |
110-
| `gbtew→` | `screen.getByText((content) => content.endsWith('░Match'))█` |
111-
| `gbteew→` | <code>screen.getByText((content, element) => {<br/>&nbsp;&nbsp;return element.tagName.toLowerCase() === '░div' && content.endsWith('░Match')<br/>})█</code> |
121+
Sorted by recommended official priority
122+
123+
1. Role
124+
125+
| Trigger | Result |
126+
| :------- | ----------------------------------------------------------------- |
127+
| `br→` | `screen.░getByRole('░id')█` |
128+
| `bro→` | `screen.░getByRole('░id', {░})█` |
129+
| `bron→` | `screen.░getByRole('░id', {name: ░})█` |
130+
| `brc→` | `screen.░getByRole('checkbox')█` |
131+
| `brcc→` | `screen.░getByRole('checkbox', { checked: ░<true\|false>} })█` |
132+
| `brh→` | `screen.░getByRole('heading')█` |
133+
| `brhl→` | `screen.░getByRole('heading', { level: ░<1\|2\|3\|4\|5\|6>} })█` |
134+
135+
4. Text
136+
137+
| Trigger | Result |
138+
| :------- | ---------------------------------------------------------------- |
139+
| `bt→` | `screen.░getByText(░)█` |
140+
| `btf→` | `screen.░getByText('░Text Match')█` |
141+
| `bti→` | `screen.░getByText('░text match', {ignore: false})█` |
142+
| `bts→` | `screen.░getByText('░ext Matc', {exact: false})█` |
143+
| `btsi→` | `screen.░getByText('░ext matc', {exact: false, ignore: false})█` |
144+
| `btsw→` | `screen.░getByText((content) => content.startsWith('░Text'))█` |
145+
| `btesw→` | <code>screen.░getByText((content, element) => {<br/>&nbsp;&nbsp;return element.tagName.toLowerCase() === '░div' && content.startsWith('░Text')<br/>})█</code> |
146+
| `btew→` | `screen.░getByText((content) => content.endsWith('░Match'))█` |
147+
| `bteew→` | <code>screen.░getByText((content, element) => {<br/>&nbsp;&nbsp;return element.tagName.toLowerCase() === '░div' && content.endsWith('░Match')<br/>})█</code> |
112148

113149
### Debug
114150

115151
| Trigger | Result |
116-
| -------: | ------------------------------------ |
117-
| `sd→` | `screen.debug()█` |
118-
| `sltp→` | `screen.logTestingPlaygroundURL()█` |
152+
| :------- | ------------------------------------ |
153+
| `sd→` | `screen.debug()█` |
154+
| `sltp→` | `screen.logTestingPlaygroundURL()█` |
119155

120156
### Regex
121157

122158
It can be used as a text matcher or `name` property on queries.
123159

124160
| Trigger | Description | Result |
125-
| ------: | --------------------------- | ------------------- |
126-
| `rf→` | full text match | `/^░Text Match$/█` |
127-
| `rfi→` | full text match ignore case | `/^░text match$/i█` |
128-
| `rs→` | substring match | `/░ext Matc/█` |
129-
| `rsi→` | substring match ignore case | `/░ext matc/i█` |
130-
| `rsw→` | start with | `/^░Text/█` |
161+
| :------ | --------------------------- | ------------------- |
162+
| `rf→` | full text match | `/^░Text Match$/█` |
163+
| `rfi→` | full text match ignore case | `/^░text match$/i█` |
164+
| `rs→` | substring match | `/░ext Matc/█` |
165+
| `rsi→` | substring match ignore case | `/░ext matc/i█` |
166+
| `rsw→` | start with | `/^░Text/█` |
131167
| `rswi→` | start with ignore case | `/^░text/i█` |
132-
| `rew→` | end with | `/░Match$/█` |
168+
| `rew→` | end with | `/░Match$/█` |
133169
| `rewi→` | end with ignore case | `/░match$/i█` |
134170

171+
### Wait
172+
173+
| Trigger | Result |
174+
| :------- | ------------------------------------------------------------------------------- |
175+
| `wf→` | <code>await waitFor(<br/>&nbsp;&nbsp;() => ░<br/>)█</code> |
176+
| `wfr→` | <code>await waitForElementToBeRemoved(<br/>&nbsp;&nbsp;() => ░<br/>)█</code> |
177+
135178
[Back to menu](#menu)
136179

137180
---

package.json

Lines changed: 1 addition & 1 deletion
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.0.5",
4+
"version": "0.0.6",
55
"displayName": "Testing Library Snippets",
66
"publisher": "deinsoftware",
77
"icon": "images/light-icon.png",

0 commit comments

Comments
 (0)