-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Fix flaky tests #9952
Fix flaky tests #9952
Conversation
djhi
commented
Jun 25, 2024
•
edited
Loading
edited
- Fix useDelete tests
- Fix create-react-admin tests
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
expect(screen.queryByText('mutating')).not.toBeNull(); | ||
}); | ||
expect(screen.queryByText('Hello')).not.toBeNull(); | ||
expect(screen.queryByText('World')).not.toBeNull(); | ||
await waitFor(() => { |
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.
the default timeout for waitFor is 1000ms. The tested story adds a delay of 1000ms to the delete. It's logical that this may fail from time to time.
I advise to reduce the delay to 500 in the story to make it more robust
@@ -20,6 +20,9 @@ test("should pass", async () => { | |||
? ` | |||
|
|||
// Sign in | |||
// Ensure the form is fully loaded before interacting with it | |||
await new Promise((resolve) => setTimeout(resolve, 1000)); |
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.
You should use an assertion in a waitfor instead of a timeout. Same for the other 2 instances
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.
We already do. I still had to add this
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.
Instead, add a timeout option to the initial findByLabelText
, as it proxies its options to waitFor
.