Skip to content

Commit cfe2b8a

Browse files
authored
Merge branch 'main' into pr/prefer-implicit-assert
2 parents 0c44edf + 7c44703 commit cfe2b8a

File tree

5 files changed

+59
-23
lines changed

5 files changed

+59
-23
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@
618618
"code",
619619
"test"
620620
]
621+
},
622+
{
623+
"login": "justintoman",
624+
"name": "justintoman",
625+
"avatar_url": "https://avatars.githubusercontent.com/u/11649507?v=4",
626+
"profile": "https://github.com/justintoman",
627+
"contributions": [
628+
"code",
629+
"test"
630+
]
621631
}
622632
],
623633
"contributorsPerLine": 7,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
423423
<tr>
424424
<td align="center" valign="top" width="14.28%"><a href="https://dale.io"><img src="https://avatars.githubusercontent.com/u/389851?v=4?s=100" width="100px;" alt="Dale Karp"/><br /><sub><b>Dale Karp</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=obsoke" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=obsoke" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=obsoke" title="Documentation">📖</a></td>
425425
<td align="center" valign="top" width="14.28%"><a href="https://github.com/nathanmmiller"><img src="https://avatars.githubusercontent.com/u/37555055?v=4?s=100" width="100px;" alt="Nathan"/><br /><sub><b>Nathan</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=nathanmmiller" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=nathanmmiller" title="Tests">⚠️</a></td>
426+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/justintoman"><img src="https://avatars.githubusercontent.com/u/11649507?v=4?s=100" width="100px;" alt="justintoman"/><br /><sub><b>justintoman</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=justintoman" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=justintoman" title="Tests">⚠️</a></td>
426427
</tr>
427428
</tbody>
428429
</table>

lib/rules/await-async-events.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const RULE_NAME = 'await-async-events';
1616
export type MessageIds = 'awaitAsyncEvent' | 'awaitAsyncEventWrapper';
1717
const FIRE_EVENT_NAME = 'fireEvent';
1818
const USER_EVENT_NAME = 'userEvent';
19+
const USER_EVENT_SETUP_FUNCTION_NAME = 'setup';
1920
type EventModules = (typeof EVENTS_SIMULATORS)[number];
2021
export type Options = [
2122
{
@@ -90,6 +91,9 @@ export default createTestingLibraryRule<Options, MessageIds>({
9091
messageId?: MessageIds;
9192
fix?: TSESLint.ReportFixFunction;
9293
}): void {
94+
if (node.name === USER_EVENT_SETUP_FUNCTION_NAME) {
95+
return;
96+
}
9397
if (!isPromiseHandled(node)) {
9498
context.report({
9599
node: closestCallExpression.callee,

package-lock.json

Lines changed: 21 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/lib/rules/await-async-events.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,29 @@ ruleTester.run(RULE_NAME, rule, {
181181
]),
182182

183183
...USER_EVENT_ASYNC_FRAMEWORKS.flatMap((testingFramework) => [
184+
{
185+
code: `
186+
import userEvent from '${testingFramework}'
187+
test('setup method called is valid', () => {
188+
userEvent.setup()
189+
})
190+
`,
191+
options: [{ eventModule: 'userEvent' }] as const,
192+
},
193+
{
194+
code: `
195+
import userEvent from '${testingFramework}'
196+
function customSetup() {
197+
return {
198+
user: userEvent.setup()
199+
};
200+
}
201+
test('setup method called and returned is valid', () => {
202+
const {user} = customSetup();
203+
})
204+
`,
205+
options: [{ eventModule: 'userEvent' }] as const,
206+
},
184207
...USER_EVENT_ASYNC_FUNCTIONS.map((eventMethod) => ({
185208
code: `
186209
import userEvent from '${testingFramework}'

0 commit comments

Comments
 (0)