Skip to content

Commit 09a910f

Browse files
robhoganfacebook-github-bot
authored andcommitted
Prepare for Jest 27+ by making legacy fake timer use explicit
Summary: Jest 27 [flips defaults](https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults), making "modern" fake timers (ie, `sinonjs/fake-timers`) the default, over "legacy", which we currently use. We're not quite ready for modern timers yet, partly due to Promise polyfills (#34659), and also some internal issues with specific tests. This makes our use of legacy timers explicit in preparation for an update to Jest. A switch to modern timers may follow later. Changelog: [Internal][Changed] - Prepare for Jest 27+ by making legacy fake timer use explicit Reviewed By: jacdebug Differential Revision: D39383719 fbshipit-source-id: 6a3dc6f8547cc76f7702a5a39c9b30a184303f17
1 parent 095f19a commit 09a910f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Libraries/Interaction/__tests__/InteractionManager-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('promise tasks', () => {
168168
}
169169
beforeEach(() => {
170170
jest.resetModules();
171-
jest.useFakeTimers();
171+
jest.useFakeTimers('legacy');
172172
InteractionManager = require('../InteractionManager');
173173
BatchedBridge = require('../../BatchedBridge/BatchedBridge');
174174
sequenceId = 0;

flow/jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ type JestObjectType = {
900900
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
901901
* setImmediate and clearImmediate).
902902
*/
903-
useFakeTimers(): JestObjectType,
903+
useFakeTimers(type?: 'legacy' | 'modern'): JestObjectType,
904904
/**
905905
* Instructs Jest to use the real versions of the standard timer functions.
906906
*/

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
'.*': './jest/private/preprocessor.js',
1717
},
1818
setupFiles: ['./jest/setup.js'],
19-
timers: 'fake',
19+
timers: 'legacy',
2020
testRegex: '/__tests__/.*-test\\.js$',
2121
testPathIgnorePatterns: [
2222
'/node_modules/',

0 commit comments

Comments
 (0)