Skip to content

Commit 175790c

Browse files
authored
Merge pull request #9 from deinsoftware/dev
Dev
2 parents ef76b2c + b01a3a1 commit 175790c

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

CHANGELOG.md

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

12+
## 0.0.9 - 2023/04/18
13+
14+
### Changed
15+
16+
- Query variant documentation
17+
1218
## 0.0.8 - 2023/04/18
1319

1420
### Changed

README.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Open the extension manager with <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>X</kbd> (W
7272

7373
## Cheat Sheet
7474

75-
You can write any combination of Search variants and Search types.
75+
You can write any combination of **Search variants** and **Search types**.
7676

7777
### Search variants
7878

@@ -89,16 +89,16 @@ You can write any combination of Search variants and Search types.
8989

9090
Sorted by oficial recommended [order of priority](https://testing-library.com/docs/queries/about/#priority).
9191

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" />` |
102102

103103
> 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)
104104
@@ -128,31 +128,33 @@ Below is a list of all available snippets and the triggers of each one. The `░
128128

129129
### Queries
130130

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+
131133
#### 1. Role
132134

133135
| Trigger | Result |
134136
| :------- | ----------------------------------------------------------------- |
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>} })█` |
142144

143145
#### 4. Text
144146

145147
| Trigger | Result |
146148
| :------- | ----------------------------------------------------------------- |
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/>&nbsp;&nbsp;const tag = element.tagName.toLowerCase() === '░div'<br/>&nbsp;&nbsp;return tag && content.startsWith('░Text')<br/>})█</code> |
154-
| `btew→` | `screen.░getByText((content) => content.endsWith('░Match'))█` |
155-
| `bteew→` | <code>screen.░getByText((content, element) => {<br/>&nbsp;&nbsp;const tag = element.tagName.toLowerCase() === '░div'<br/>&nbsp;&nbsp;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/>&nbsp;&nbsp;const tag = element.tagName.toLowerCase() === '░div'<br/>&nbsp;&nbsp;return tag && content.startsWith('░Text')<br/>})█</code> |
156+
| `btew→` | `screen.░variantText((content) => content.endsWith('░Match'))█` |
157+
| `bteew→` | <code>screen.░variantText((content, element) => {<br/>&nbsp;&nbsp;const tag = element.tagName.toLowerCase() === '░div'<br/>&nbsp;&nbsp;return tag && content.endsWith('░Match')<br/>})█</code> |
156158

157159
### Debug
158160

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.8",
4+
"version": "0.0.9",
55
"displayName": "Testing Library Snippets",
66
"publisher": "deinsoftware",
77
"icon": "images/light-icon.png",

0 commit comments

Comments
 (0)