Follow these instructions to reproduce the problem:
git clone [email protected]:juan-fernandez/jest-reproducible-case.git
cd jest-reproducible-case
yarn
yarn test Button.test.tsx --no-cache
See the error is the following:
FAIL ./Button.test.tsx
tests
✕ should show login form (609 ms)
✓ should show login form 2 (393 ms)
● tests › should show login form
thrown: "Exceeded timeout of 400 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."
13 |
14 | describe('tests', () => {
> 15 | test('should show login form', async () => {
| ^
16 | await runTest()
17 | })
18 | test('should show login form 2', async () => {
at Button.test.tsx:15:3
at Object.<anonymous> (Button.test.tsx:14:1)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 3.403 s
This test file is exactly the same as Button.test.tsx
but the order of the tests is changed:
yarn test Button2.test.tsx --no-cache
FAIL ./Button2.test.tsx
tests
✕ should show login form 2 (577 ms)
✓ should show login form (378 ms)
● tests › should show login form 2
thrown: "Exceeded timeout of 400 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."
13 |
14 | describe('tests', () => {
> 15 | test('should show login form 2', async () => {
| ^
16 | await runTest()
17 | })
18 | test('should show login form', async () => {
at Button2.test.tsx:15:3
at Object.<anonymous> (Button2.test.tsx:14:1)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 total
Time: 3.244 s
Even though Button.test.tsx
and Button2.test.tsx
are running the same tests but in a different order, the only test that times out is the first one, regardless of what the tests are doing.
The tests behave the same timing-wise.