-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade package @testing-library/user-event from 12.8.3 to 14.5.2 #2605
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -628,7 +628,11 @@ describe('Testing Advertisement Register Component', () => { | |||||||||||||||
type: 'video/mp4', | ||||||||||||||||
}); | ||||||||||||||||
const mediaInput = screen.getByTestId('advertisementMedia'); | ||||||||||||||||
userEvent.upload(mediaInput, mediaFile); | ||||||||||||||||
fireEvent.change(mediaInput, { | ||||||||||||||||
target: { | ||||||||||||||||
files: [mediaFile], | ||||||||||||||||
}, | ||||||||||||||||
}); | ||||||||||||||||
Comment on lines
+631
to
+635
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using userEvent.upload for file inputs The change from - fireEvent.change(mediaInput, {
- target: {
- files: [mediaFile],
- },
- });
+ const user = userEvent.setup();
+ await user.upload(mediaInput, mediaFile); 📝 Committable suggestion
Suggested change
|
||||||||||||||||
|
||||||||||||||||
const mediaPreview = await screen.findByTestId('mediaPreview'); | ||||||||||||||||
expect(mediaPreview).toBeInTheDocument(); | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Replace fixed timeout with waitFor
Using a fixed timeout of 3 seconds for waiting for navigation is brittle and could lead to flaky tests:
This approach is more reliable as it will complete as soon as the condition is met, without always waiting for the full duration.
📝 Committable suggestion