Skip to content

Commit 0555411

Browse files
committed
refactor: remove real timers warning in User Event
1 parent 239e046 commit 0555411

File tree

6 files changed

+1
-98
lines changed

6 files changed

+1
-98
lines changed

src/user-event/press/__tests__/longPress.real-timers.test.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import React from 'react';
22
import { Pressable, Text } from 'react-native';
33
import { render, screen } from '../../../pure';
44
import { userEvent } from '../..';
5-
import * as WarnAboutRealTimers from '../../utils/warn-about-real-timers';
65

76
describe('userEvent.longPress with real timers', () => {
87
beforeEach(() => {
98
jest.useRealTimers();
109
jest.restoreAllMocks();
11-
jest.spyOn(WarnAboutRealTimers, 'warnAboutRealTimersIfNeeded').mockImplementation();
1210
});
1311

1412
test('calls onLongPress if the delayLongPress is the default one', async () => {
@@ -90,18 +88,3 @@ describe('userEvent.longPress with real timers', () => {
9088
expect(mockOnLongPress).toHaveBeenCalled();
9189
});
9290
});
93-
94-
test('warns about using real timers with userEvent', async () => {
95-
jest.restoreAllMocks();
96-
const mockConsoleWarn = jest.spyOn(console, 'warn').mockImplementation();
97-
98-
render(<Pressable testID="pressable" />);
99-
100-
await userEvent.longPress(screen.getByTestId('pressable'));
101-
102-
expect(mockConsoleWarn.mock.calls[0][0]).toMatchInlineSnapshot(`
103-
"It is recommended to use userEvent with fake timers
104-
Some events involve duration so your tests may take a long time to run.
105-
For instance calling userEvent.longPress with real timers will take 500 ms."
106-
`);
107-
});

src/user-event/press/__tests__/press.real-timers.test.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import {
1010
import { createEventLogger, getEventsNames } from '../../../test-utils';
1111
import { render, screen } from '../../..';
1212
import { userEvent } from '../..';
13-
import * as WarnAboutRealTimers from '../../utils/warn-about-real-timers';
1413

1514
describe('userEvent.press with real timers', () => {
1615
beforeEach(() => {
1716
jest.useRealTimers();
1817
jest.restoreAllMocks();
19-
jest.spyOn(WarnAboutRealTimers, 'warnAboutRealTimersIfNeeded').mockImplementation();
2018
});
2119

2220
test('calls onPressIn, onPress and onPressOut prop of touchable', async () => {
@@ -301,18 +299,3 @@ describe('userEvent.press with real timers', () => {
301299
expect(mockOnPress).toHaveBeenCalled();
302300
});
303301
});
304-
305-
test('warns about using real timers with userEvent', async () => {
306-
jest.restoreAllMocks();
307-
const mockConsoleWarn = jest.spyOn(console, 'warn').mockImplementation();
308-
309-
render(<Pressable testID="pressable" />);
310-
311-
await userEvent.press(screen.getByTestId('pressable'));
312-
313-
expect(mockConsoleWarn.mock.calls[0][0]).toMatchInlineSnapshot(`
314-
"It is recommended to use userEvent with fake timers
315-
Some events involve duration so your tests may take a long time to run.
316-
For instance calling userEvent.longPress with real timers will take 500 ms."
317-
`);
318-
});

src/user-event/press/press.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isPointerEventEnabled } from '../../helpers/pointer-events';
66
import { isHostText, isHostTextInput } from '../../helpers/host-component-names';
77
import { EventBuilder } from '../event-builder';
88
import { UserEventConfig, UserEventInstance } from '../setup';
9-
import { dispatchEvent, wait, warnAboutRealTimersIfNeeded } from '../utils';
9+
import { dispatchEvent, wait } from '../utils';
1010
import { DEFAULT_MIN_PRESS_DURATION } from './constants';
1111

1212
export interface PressOptions {
@@ -69,8 +69,6 @@ const emitPressablePressEvents = async (
6969
element: ReactTestInstance,
7070
options: BasePressOptions,
7171
) => {
72-
warnAboutRealTimersIfNeeded();
73-
7472
await wait(config);
7573

7674
dispatchEvent(element, 'responderGrant', EventBuilder.Common.responderGrant());

src/user-event/utils/__tests__/warn-about-real-timers.test.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/user-event/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ export * from './content-size';
22
export * from './dispatch-event';
33
export * from './text-range';
44
export * from './wait';
5-
export * from './warn-about-real-timers';

src/user-event/utils/warn-about-real-timers.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)