-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use runAllTimers when running fakeTimers
- Loading branch information
1 parent
3707c1a
commit 0ef9797
Showing
4 changed files
with
69 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
e2e/test-retries/__tests__/logErrorsBeforeRetriesFakeTimers.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
let i = 0; | ||
const startTimeInSeconds = new Date().getTime(); | ||
jest.retryTimes(3, {logErrorsBeforeRetry: true, waitBeforeRetry: 100}); | ||
it('retryTimes set with fake timers', () => { | ||
jest.useFakeTimers(); | ||
i++; | ||
if (i === 3) { | ||
expect(new Date().getTime() - startTimeInSeconds).toBeGreaterThan( | ||
200, | ||
); | ||
} else { | ||
expect(true).toBeFalsy(); | ||
jest.runAllTimers(); | ||
} | ||
}); |