mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
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 (https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
095f19a681
commit
09a910f80b
@@ -168,7 +168,7 @@ describe('promise tasks', () => {
|
||||
}
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
jest.useFakeTimers();
|
||||
jest.useFakeTimers('legacy');
|
||||
InteractionManager = require('../InteractionManager');
|
||||
BatchedBridge = require('../../BatchedBridge/BatchedBridge');
|
||||
sequenceId = 0;
|
||||
|
||||
+1
-1
@@ -900,7 +900,7 @@ type JestObjectType = {
|
||||
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
|
||||
* setImmediate and clearImmediate).
|
||||
*/
|
||||
useFakeTimers(): JestObjectType,
|
||||
useFakeTimers(type?: 'legacy' | 'modern'): JestObjectType,
|
||||
/**
|
||||
* Instructs Jest to use the real versions of the standard timer functions.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = {
|
||||
'.*': './jest/private/preprocessor.js',
|
||||
},
|
||||
setupFiles: ['./jest/setup.js'],
|
||||
timers: 'fake',
|
||||
timers: 'legacy',
|
||||
testRegex: '/__tests__/.*-test\\.js$',
|
||||
testPathIgnorePatterns: [
|
||||
'/node_modules/',
|
||||
|
||||
Reference in New Issue
Block a user