Skip to content

Commit 942fa49

Browse files
committed
fix: Flaky test
This commit is unrelated to the current PR, but it's required for the CI to pass and the local pre-push hook to pass
1 parent 61e7352 commit 942fa49

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

__tests__/pages/exercises/[lessonSlug].test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import React from 'react'
2-
import { render, screen, fireEvent } from '@testing-library/react'
2+
import {
3+
render,
4+
screen,
5+
fireEvent,
6+
waitForElementToBeRemoved
7+
} from '@testing-library/react'
38
import '@testing-library/jest-dom'
49
import Exercises from '../../../pages/exercises/[lessonSlug]'
510
import { useRouter } from 'next/router'
@@ -342,6 +347,11 @@ describe('Exercises page', () => {
342347
</MockedProvider>
343348
)
344349

345-
await screen.findByText('Loading...')
350+
// there are two spinners, one from withQueryLoader, another from useRouter, so we need to wait to test the second one
351+
expect(
352+
await waitForElementToBeRemoved(() => screen.queryByText('Loading...'), {
353+
onTimeout: () => {}
354+
})
355+
).toBeNull()
346356
})
347357
})

0 commit comments

Comments
 (0)