Skip to content
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

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Fix flaky tests #9952

merged 4 commits into from
Jun 26, 2024

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Jun 25, 2024

  • Fix useDelete tests
  • Fix create-react-admin tests

@djhi djhi added the WIP Work In Progress label Jun 25, 2024
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(() => {
Copy link
Member

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));
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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.

@fzaninotto fzaninotto merged commit 060d38e into master Jun 26, 2024
14 checks passed
@fzaninotto fzaninotto deleted the fix-flaky-tests branch June 26, 2024 14:03
@fzaninotto fzaninotto added this to the 5.0.2 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants