fix: detect userEvent imported from custom module#1264
fix: detect userEvent imported from custom module#1264Belco90 merged 3 commits intotesting-library:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1264 +/- ##
=======================================
Coverage 97.35% 97.35%
=======================================
Files 49 49
Lines 6012 6020 +8
Branches 1538 1544 +6
=======================================
+ Hits 5853 5861 +8
Misses 157 157
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Belco90
left a comment
There was a problem hiding this comment.
The bug fix looks fine to me, good job! Especially with the tests, those are great.
Codecov is complaining about the code coverage went down tho. What I'd do is adding new tests to tests/create-testing-library-rule.test.ts to cover the new user-event detection.
|
Thanks for the review! @Belco90 Tests added to |
Belco90
left a comment
There was a problem hiding this comment.
LGTM. The lines not covered are fine, so I'm skipping that.
|
@all-contributors please add @snvfyy for code and test |
|
I've put up a pull request to add @snvfyy! 🎉 |
|
🎉 This PR is included in version 7.16.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Checks
Changes
Adding a fallback to check the custom module import, similar to how
findImportedTestingLibraryUtilSpecifieralready does for other utils likefireEvent.Affected rules:
await-async-events,no-await-sync-events,no-unnecessary-act,no-wait-for-side-effects.Context
Partially fixes #1253
When userEvent is imported from a custom module, rules relying on
isUserEventUtilorisUserEventMethoddon't detect it. This is becausefindImportedUserEventSpecifieronly checks for@testing-library/user-eventand not at custom modules.We're fixing everything except
prefer-user-event-setup. That one has a different root cause (it doesn't use the shared helpers), so thefindImportedUserEventSpecifierfix doesn't help it.