Skip to content

Commit a5a8658

Browse files
committed
update cheatsheet readme
1 parent 5d6ae9a commit a5a8658

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
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.8 - 2023/04/18
13+
14+
### Changed
15+
16+
- Cheat sheet based on official documentation
17+
1218
## 0.0.7 - 2023/04/17
1319

1420
### Fixed

README.md

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

7373
## Cheat Sheet
7474

75-
### Variants
76-
77-
| Search | Result |
78-
| ---------------- | --------------------------------------------- |
79-
| `getBy`... | `Element` or `Error` |
80-
| `getAllBy`... | `Element[]` or `Error` |
81-
| `queryBy`... | `Element` or `null` |
82-
| `queryAllBy`... | `Element[]` or `null` |
83-
| `findBy`... | `Promise<Element>` or `Promise<rejection>` |
84-
| `findAllBy`... | `Promise<Element[]>` or `Promise<rejection>` |
85-
86-
### Types
87-
88-
| Search | Result |
89-
| --------------------- | --------------------------------------------- |
90-
| ...`Role` | `<div aria="role">` or [Aria Roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) |
91-
| ...`LabelText` | `<label for="Text">` |
92-
| ...`PlaceHolderText` | `<input placeholder="Text">` |
93-
| ...`Text` | `<a href="/page">Text</a>` |
94-
| ...`DisplayValue` | `<input value="Text">` |
95-
| ...`AltText` | `<img alt="Text">` |
96-
| ...`Title` | `<span title="Text">` or `<title>` |
97-
| ...`TestId` | `<input data-testid="Id">` |
75+
You can write any combination of Search variants and Search types.
76+
77+
### Search variants
78+
79+
| Variants | Return if no match | Return if 1 match | Return if 1+ match | Await? |
80+
| --------------- | ------------------ | ----------------- | ------------------ | ------ |
81+
| `getBy`... | throw | return | throw | No |
82+
| `getAllBy`... | throw | array | array | No |
83+
| `queryBy`... | `null` | return | throw | No |
84+
| `queryAllBy`... | `[]` | array | array | No |
85+
| `findBy`... | throw | return | throw | Yes |
86+
| `findAllBy`... | throw | array | array | Yes |
87+
88+
### Search types
89+
90+
Sorted by oficial recommended [order of priority](https://testing-library.com/docs/queries/about/#priority).
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" />` |
102+
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)
98104
99105
[Back to menu](#menu)
100106

@@ -122,8 +128,6 @@ Below is a list of all available snippets and the triggers of each one. The `░
122128

123129
### Queries
124130

125-
Sorted by recommended official priority
126-
127131
#### 1. Role
128132

129133
| Trigger | Result |

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

0 commit comments

Comments
 (0)