testing-library / eslint-plugin-testing-library

ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
https://npm.im/eslint-plugin-testing-library
MIT License
982 stars 137 forks source link

fix(await-async-events): false positives for userEvent.setup() returned #895

Closed Chamion closed 5 months ago

Chamion commented 5 months ago

Checks

Changes

The circuit-breaker checking for userEvent.setup() was executed after detectEventMethodWrapper so the circuit-breaking only applied to cases where the expression is not returned. It's intended to be applied generally so this PR moves it to the top of its code block.

Context

My last contribution was received well so I picked another open issue.

Fixes #881

This is another false-positive where the root problem is defaulting to report unless a reason not to report is found. If new methods are introduced to userEvent the rule will assume they return promises. I'd like to change the behaviour to check for an allow-list of method names instead of checking it's not specifically setup so future bugs would be false negatives instead of false positives. I didn't do that in this PR because maybe it's the way it is by design.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.31%. Comparing base (93a6ab9) to head (7837d4f). Report is 5 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #895 +/- ## ========================================== + Coverage 96.23% 96.31% +0.08% ========================================== Files 44 44 Lines 2419 2445 +26 Branches 1000 1023 +23 ========================================== + Hits 2328 2355 +27 + Misses 91 90 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Belco90 commented 5 months ago

@all-contributors please add @Chamion for code, test

allcontributors[bot] commented 5 months ago

@Belco90

I've put up a pull request to add @Chamion! :tada:

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 6.2.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: