Skip to content
Merged
Prev Previous commit
Next Next commit
Use new API to enable legacy fake timers
  • Loading branch information
jsnajdr committed Mar 8, 2023
commit ec085d505d8995d8526941b5a711244111b8fc8d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TestScreen = ( { fullScreen, name, navigateTo } ) => {
};

beforeAll( () => {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
} );

afterAll( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render, fireEvent, waitFor } from 'test/helpers';
import LinkSettingsNavigation from '../link-settings-navigation';

beforeAll( () => {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
} );

afterAll( () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/test/privateAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { unlock } from '../private-apis';
*/

beforeEach( () => {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
} );

afterEach( () => {
Expand Down
9 changes: 1 addition & 8 deletions packages/data/src/test/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ import { createRegistrySelector } from '../factory';
import createReduxStore from '../redux-store';
import coreDataStore from '../store';

beforeEach( () => {
jest.useFakeTimers( 'legacy' );
} );

afterEach( () => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
} );
jest.useFakeTimers( { legacyFakeTimers: true } );

describe( 'createRegistry', () => {
let registry;
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/test/editor.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const unsupportedBlock = `
`;

beforeAll( () => {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
} );

afterAll( () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/editor/src/components/autosave-monitor/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ import { render } from '@testing-library/react';
*/
import { AutosaveMonitor } from '../';

jest.useFakeTimers( { legacyFakeTimers: true } );

describe( 'AutosaveMonitor', () => {
let setAutosaveTimerSpy;
beforeEach( () => {
jest.useFakeTimers( 'legacy' );
setAutosaveTimerSpy = jest.spyOn(
AutosaveMonitor.prototype,
'setAutosaveTimer'
);
} );

afterEach( () => {
jest.runOnlyPendingTimers();
jest.useRealTimers();

setAutosaveTimerSpy.mockClear();
} );

Expand Down
2 changes: 1 addition & 1 deletion packages/format-library/src/link/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const LinkEditSlot = ( props ) => (
jest.spyOn( Keyboard, 'dismiss' );

beforeAll( () => {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
} );

afterAll( () => {
Expand Down
2 changes: 1 addition & 1 deletion test/native/integration-test-helpers/with-fake-timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function withFakeTimers( fn ) {
const cancelAnimationFrameCopy = global.cancelAnimationFrame;

if ( ! usingFakeTimers ) {
jest.useFakeTimers( 'legacy' );
jest.useFakeTimers( { legacyFakeTimers: true } );
}

const result = await fn();
Expand Down