Skip to content

Commit 83d45e5

Browse files
committed
Merge remote-tracking branch 'origin/main' into alpha
# Conflicts: # README.md # docs/rules/await-fire-event.md # docs/rules/no-render-in-lifecycle.md # docs/rules/prefer-wait-for.md # lib/rules/await-fire-event.ts # tests/__snapshots__/index.test.ts.snap # tests/index.test.ts # tests/lib/rules/await-fire-event.test.ts
2 parents 9d5554c + 25f73c5 commit 83d45e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+566
-472
lines changed

.all-contributorsrc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,36 @@
544544
"code",
545545
"test"
546546
]
547+
},
548+
{
549+
"login": "NickBolles",
550+
"name": "Nick Bolles",
551+
"avatar_url": "https://avatars.githubusercontent.com/u/7891759?v=4",
552+
"profile": "https://nickbolles.com",
553+
"contributions": [
554+
"code",
555+
"test",
556+
"doc"
557+
]
558+
},
559+
{
560+
"login": "bmish",
561+
"name": "Bryan Mishkin",
562+
"avatar_url": "https://avatars.githubusercontent.com/u/698306?v=4",
563+
"profile": "http://www.linkedin.com/in/bmish",
564+
"contributions": [
565+
"doc",
566+
"tool"
567+
]
568+
},
569+
{
570+
"login": "theredspoon",
571+
"name": "Nim G",
572+
"avatar_url": "https://avatars.githubusercontent.com/u/20975696?v=4",
573+
"profile": "https://github.com/theredspoon",
574+
"contributions": [
575+
"doc"
576+
]
547577
}
548578
],
549579
"contributorsPerLine": 7,

.github/pull_request_template.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## Checks
22

33
- [ ] I have read the [contributing guidelines](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/CONTRIBUTING.md).
4-
- [ ] If some rule is added/updated/removed, I've regenerated the rules list (`npm run generate:rules-list`)
5-
- [ ] If some rule meta info is changed, I've regenerated the plugin shared configs (`npm run generate:configs`)
64

75
## Changes
86

.github/workflows/pipeline.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Cancel Previous Runs
24-
uses: styfle/cancel-workflow-action@0.10.1
24+
uses: styfle/cancel-workflow-action@0.11.0
2525

2626
- name: Checkout
2727
uses: actions/checkout@v3
@@ -45,6 +45,9 @@ jobs:
4545
- name: Check format
4646
run: npm run format:check
4747

48+
- name: Check autogenerated docs
49+
run: npm run docs:gen && npm run format && git diff --exit-code
50+
4851
tests:
4952
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
5053
runs-on: ubuntu-latest
@@ -56,7 +59,7 @@ jobs:
5659

5760
steps:
5861
- name: Cancel Previous Runs
59-
uses: styfle/cancel-workflow-action@0.10.1
62+
uses: styfle/cancel-workflow-action@0.11.0
6063

6164
- name: Checkout
6265
uses: actions/checkout@v3
@@ -88,7 +91,7 @@ jobs:
8891

8992
steps:
9093
- name: Cancel Previous Runs
91-
uses: styfle/cancel-workflow-action@0.10.1
94+
uses: styfle/cancel-workflow-action@0.11.0
9295

9396
- name: Checkout
9497
uses: actions/checkout@v3

.gitpod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tasks:
2+
- init: npm install

README.md

Lines changed: 95 additions & 92 deletions
Large diffs are not rendered by default.

docs/rules/await-async-queries.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Enforce promises from async queries to be handled (`testing-library/await-async-queries`)
22

3+
💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Ensure that promises returned by async queries are handled properly.
48

59
## Rule Details
@@ -19,6 +23,7 @@ problems in the tests. The promise will be considered as handled when:
1923
- wrapped within `Promise.all` or `Promise.allSettled` methods
2024
- chaining the `then` method
2125
- chaining `resolves` or `rejects` from jest
26+
- chaining `toResolve()` or `toReject()` from [jest-extended](https://github.com/jest-community/jest-extended#promise)
2227
- it's returned from a function (in this case, that particular function will be analyzed by this rule too)
2328

2429
Examples of **incorrect** code for this rule:
@@ -90,6 +95,12 @@ expect(findByTestId('alert')).resolves.toBe('Success');
9095
expect(findByTestId('alert')).rejects.toBe('Error');
9196
```
9297

98+
```js
99+
// using a toResolve/toReject matcher is also correct
100+
expect(findByTestId('alert')).toResolve();
101+
expect(findByTestId('alert')).toReject();
102+
```
103+
93104
```js
94105
// sync queries don't need to handle any promise
95106
const element = getByRole('role');

docs/rules/await-async-utils.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Enforce promises from async utils to be handled (`testing-library/await-async-utils`)
1+
# Enforce promises from async utils to be awaited properly (`testing-library/await-async-utils`)
2+
3+
💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`.
4+
5+
<!-- end auto-generated rule header -->
26

37
Ensure that promises returned by async utils are handled properly.
48

@@ -20,6 +24,7 @@ problems in the tests. The promise will be considered as handled when:
2024
- wrapped within `Promise.all` or `Promise.allSettled` methods
2125
- chaining the `then` method
2226
- chaining `resolves` or `rejects` from jest
27+
- chaining `toResolve()` or `toReject()` from [jest-extended](https://github.com/jest-community/jest-extended#promise)
2328
- it's returned from a function (in this case, that particular function will be analyzed by this rule too)
2429

2530
Examples of **incorrect** code for this rule:
@@ -85,6 +90,12 @@ test('something correctly', async () => {
8590
waitFor(() => getByLabelText('email')),
8691
waitForElementToBeRemoved(() => document.querySelector('div.getOuttaHere')),
8792
]);
93+
94+
// Using jest resolves or rejects
95+
expect(waitFor(() => getByLabelText('email'))).resolves.toBeUndefined();
96+
97+
// Using jest-extended a toResolve/toReject matcher is also correct
98+
expect(waitFor(() => getByLabelText('email'))).toResolve();
8899
});
89100
```
90101

docs/rules/consistent-data-testid.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Enforces consistent naming for the data-testid attribute (`testing-library/consistent-data-testid`)
1+
# Ensures consistent usage of `data-testid` (`testing-library/consistent-data-testid`)
2+
3+
<!-- end auto-generated rule header -->
24

35
Ensure `data-testid` values match a provided regex. This rule is un-opinionated, and requires configuration.
46

docs/rules/no-await-sync-events.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow unnecessary `await` for sync events (`testing-library/no-await-sync-events`)
22

3+
<!-- end auto-generated rule header -->
4+
35
Ensure that sync simulated events are not awaited unnecessarily.
46

57
## Rule Details

docs/rules/no-await-sync-queries.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Disallow unnecessary `await` for sync queries (`testing-library/no-await-sync-queries`)
22

3+
💼 This rule is enabled in the following configs: `angular`, `dom`, `marko`, `react`, `vue`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Ensure that sync queries are not awaited unnecessarily.
48

59
## Rule Details

0 commit comments

Comments
 (0)