From 3710490c8f2ec10a034911f988bf0d295cbba21e Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 3 May 2022 16:07:13 +0200 Subject: [PATCH] Use fake timers --- packages/components/src/unit-control/test/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/components/src/unit-control/test/index.tsx b/packages/components/src/unit-control/test/index.tsx index b8d7b86b35ac5..46f819d90ea61 100644 --- a/packages/components/src/unit-control/test/index.tsx +++ b/packages/components/src/unit-control/test/index.tsx @@ -19,8 +19,7 @@ import type { UnitControlOnChangeCallback } from '../types'; function render( jsx: React.ReactElement ) { return { user: userEvent.setup( { - // Avoids timeout errors (https://github.com/testing-library/user-event/issues/565#issuecomment-1064579531). - delay: null, + advanceTimers: jest.advanceTimersByTime, } ), ...RTLrender( jsx ), }; @@ -98,6 +97,15 @@ const ControlledSyncUnits = () => { }; describe( 'UnitControl', () => { + beforeEach( () => { + jest.useFakeTimers(); + } ); + + afterEach( () => { + jest.runOnlyPendingTimers(); + jest.useRealTimers(); + } ); + describe( 'Basic rendering', () => { it( 'should render', () => { render( );