Skip to content

Commit 1a87f42

Browse files
committed
Revert "Ignore infinite timers in tests"
This reverts commit 97ffdbb. No longer needed now that we stop resetting outside render.
1 parent 2ee6f47 commit 1a87f42

22 files changed

+70
-75
lines changed

packages/react-devtools-shared/src/__tests__/bridge-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ describe('Bridge', () => {
2626

2727
// Check that we're wired up correctly.
2828
bridge.send('reloadAppForProfiling');
29-
jest.runOnlyPendingTimers();
29+
jest.runAllTimers();
3030
expect(wall.send).toHaveBeenCalledWith('reloadAppForProfiling');
3131

3232
// Should flush pending messages and then shut down.
3333
wall.send.mockClear();
3434
bridge.send('update', '1');
3535
bridge.send('update', '2');
3636
bridge.shutdown();
37-
jest.runOnlyPendingTimers();
37+
jest.runAllTimers();
3838
expect(wall.send).toHaveBeenCalledWith('update', '1');
3939
expect(wall.send).toHaveBeenCalledWith('update', '2');
4040
expect(wall.send).toHaveBeenCalledWith('shutdown');
@@ -44,7 +44,7 @@ describe('Bridge', () => {
4444
jest.spyOn(console, 'warn').mockImplementation(() => {});
4545
wall.send.mockClear();
4646
bridge.send('should not send');
47-
jest.runOnlyPendingTimers();
47+
jest.runAllTimers();
4848
expect(wall.send).not.toHaveBeenCalled();
4949
expect(console.warn).toHaveBeenCalledWith(
5050
'Cannot send message "should not send" through a Bridge that has been shutdown.',

packages/react-devtools-shared/src/__tests__/legacy/editing-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('editing interface', () => {
2020
const act = (callback: Function) => {
2121
callback();
2222

23-
jest.runOnlyPendingTimers(); // Flush Bridge operations
23+
jest.runAllTimers(); // Flush Bridge operations
2424
};
2525

2626
const flushPendingUpdates = () => {

packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('InspectedElementContext', () => {
2121
const act = (callback: Function) => {
2222
callback();
2323

24-
jest.runOnlyPendingTimers(); // Flush Bridge operations
24+
jest.runAllTimers(); // Flush Bridge operations
2525
};
2626

2727
async function read(

packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Store (legacy)', () => {
1313
let store;
1414
const act = (callback: Function) => {
1515
callback();
16-
jest.runOnlyPendingTimers(); // Flush Bridge operations
16+
jest.runAllTimers(); // Flush Bridge operations
1717
};
1818
beforeEach(() => {
1919
store = global.store;

packages/react-devtools-shared/src/__tests__/store-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ describe('Store', () => {
19781978
clearErrorsAndWarnings({bridge, store});
19791979

19801980
// flush events to the renderer
1981-
jest.runOnlyPendingTimers();
1981+
jest.runAllTimers();
19821982

19831983
expect(store).toMatchInlineSnapshot(`
19841984
[root]
@@ -2022,7 +2022,7 @@ describe('Store', () => {
20222022
clearWarningsForElement({bridge, id, rendererID});
20232023

20242024
// Flush events to the renderer.
2025-
jest.runOnlyPendingTimers();
2025+
jest.runAllTimers();
20262026

20272027
expect(store).toMatchInlineSnapshot(`
20282028
✕ 2, ⚠ 1
@@ -2067,7 +2067,7 @@ describe('Store', () => {
20672067
clearErrorsForElement({bridge, id, rendererID});
20682068

20692069
// Flush events to the renderer.
2070-
jest.runOnlyPendingTimers();
2070+
jest.runAllTimers();
20712071

20722072
expect(store).toMatchInlineSnapshot(`
20732073
✕ 1, ⚠ 2

packages/react-devtools-shared/src/__tests__/treeContext-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1421,21 +1421,21 @@ describe('TreeListContext', () => {
14211421
function clearAllErrors() {
14221422
utils.act(() => clearErrorsAndWarningsAPI({bridge, store}));
14231423
// flush events to the renderer
1424-
jest.runOnlyPendingTimers();
1424+
jest.runAllTimers();
14251425
}
14261426

14271427
function clearErrorsForElement(id) {
14281428
const rendererID = store.getRendererIDForElement(id);
14291429
utils.act(() => clearErrorsForElementAPI({bridge, id, rendererID}));
14301430
// flush events to the renderer
1431-
jest.runOnlyPendingTimers();
1431+
jest.runAllTimers();
14321432
}
14331433

14341434
function clearWarningsForElement(id) {
14351435
const rendererID = store.getRendererIDForElement(id);
14361436
utils.act(() => clearWarningsForElementAPI({bridge, id, rendererID}));
14371437
// flush events to the renderer
1438-
jest.runOnlyPendingTimers();
1438+
jest.runAllTimers();
14391439
}
14401440

14411441
function selectNextErrorOrWarning() {
@@ -2358,7 +2358,7 @@ describe('TreeListContext', () => {
23582358
);
23592359
utils.act(() => TestRenderer.create(<Contexts />));
23602360

2361-
jest.runOnlyPendingTimers();
2361+
jest.runAllTimers();
23622362

23632363
expect(state).toMatchInlineSnapshot(`
23642364
[root]

packages/react-devtools-shared/src/__tests__/utils.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ export function act(
8181

8282
if (recursivelyFlush) {
8383
// Flush Bridge operations
84-
// We have always one pending timer running that resets the Owner Stack limit.
85-
while (jest.getTimerCount() > 1) {
84+
while (jest.getTimerCount() > 0) {
8685
actDOM(() => {
8786
actTestRenderer(() => {
88-
jest.runOnlyPendingTimers();
87+
jest.runAllTimers();
8988
});
9089
});
9190
}
@@ -108,11 +107,10 @@ export async function actAsync(
108107
});
109108

110109
if (recursivelyFlush) {
111-
// We have always one pending timer running that resets the Owner Stack limit.
112-
while (jest.getTimerCount() > 1) {
110+
while (jest.getTimerCount() > 0) {
113111
await actDOM(async () => {
114112
await actTestRenderer(async () => {
115-
jest.runOnlyPendingTimers();
113+
jest.runAllTimers();
116114
});
117115
});
118116
}

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2881,7 +2881,7 @@ describe('ReactDOMFizzServer', () => {
28812881
root.render(<App color="blue" />);
28822882
});
28832883
await waitForAll([]);
2884-
jest.runOnlyPendingTimers();
2884+
jest.runAllTimers();
28852885
const clientFallback2 = container.getElementsByTagName('p')[0];
28862886
expect(clientFallback2).toBe(serverFallback);
28872887

@@ -2987,7 +2987,7 @@ describe('ReactDOMFizzServer', () => {
29872987
// actually force it to re-render on the client and throw away the server one.
29882988
root.render(<App fallbackText="More loading..." />);
29892989
await waitForAll([]);
2990-
jest.runOnlyPendingTimers();
2990+
jest.runAllTimers();
29912991
assertLog([
29922992
'onRecoverableError: The server could not finish this Suspense boundary, ' +
29932993
'likely due to an error during server rendering. ' +
@@ -6414,7 +6414,7 @@ describe('ReactDOMFizzServer', () => {
64146414
ref.current.dispatchEvent(
64156415
new window.MouseEvent('click', {bubbles: true}),
64166416
);
6417-
await jest.runOnlyPendingTimers();
6417+
await jest.runAllTimers();
64186418
expect(getVisibleChildren(container)).toEqual(<button>1</button>);
64196419
});
64206420

packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ describe('ReactDOMFizzServerNode', () => {
144144
},
145145
},
146146
);
147-
await jest.runOnlyPendingTimers();
147+
await jest.runAllTimers();
148148
expect(output.result).toBe('');
149149
expect(isCompleteCalls).toBe(0);
150150
// Resolve the loading.
151151
hasLoaded = true;
152152
await resolve();
153153

154-
await jest.runOnlyPendingTimers();
154+
await jest.runAllTimers();
155155

156156
expect(output.result).toBe('');
157157
expect(isCompleteCalls).toBe(1);
@@ -354,7 +354,7 @@ describe('ReactDOMFizzServerNode', () => {
354354
const theReason = new Error('uh oh');
355355
abort(theReason);
356356

357-
jest.runOnlyPendingTimers();
357+
jest.runAllTimers();
358358

359359
await completed;
360360

@@ -632,7 +632,7 @@ describe('ReactDOMFizzServerNode', () => {
632632

633633
writable.end();
634634

635-
await jest.runOnlyPendingTimers();
635+
await jest.runAllTimers();
636636

637637
hasLoaded = true;
638638
resolve();

packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
225225
),
226226
);
227227

228-
await jest.runOnlyPendingTimers();
228+
await jest.runAllTimers();
229229

230230
// Resolve the loading.
231231
hasLoaded = true;
@@ -354,7 +354,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
354354
),
355355
);
356356

357-
await jest.runOnlyPendingTimers();
357+
await jest.runAllTimers();
358358

359359
const theReason = new Error('aborted for reasons');
360360
controller.abort(theReason);
@@ -387,7 +387,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
387387
),
388388
);
389389

390-
await jest.runOnlyPendingTimers();
390+
await jest.runAllTimers();
391391

392392
const theReason = new Error('aborted for reasons');
393393
controller.abort(theReason);
@@ -1377,7 +1377,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
13771377
),
13781378
);
13791379

1380-
await jest.runOnlyPendingTimers();
1380+
await jest.runAllTimers();
13811381

13821382
expect(getVisibleChildren(container)).toEqual(<div>Loading...</div>);
13831383

packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('ReactDOMFizzStaticNode', () => {
103103
</div>,
104104
);
105105

106-
await jest.runOnlyPendingTimers();
106+
await jest.runAllTimers();
107107

108108
// Resolve the loading.
109109
hasLoaded = true;
@@ -199,7 +199,7 @@ describe('ReactDOMFizzStaticNode', () => {
199199
},
200200
);
201201

202-
await jest.runOnlyPendingTimers();
202+
await jest.runAllTimers();
203203

204204
controller.abort();
205205

@@ -228,7 +228,7 @@ describe('ReactDOMFizzStaticNode', () => {
228228
},
229229
);
230230

231-
await jest.runOnlyPendingTimers();
231+
await jest.runAllTimers();
232232

233233
const theReason = new Error('aborted for reasons');
234234
controller.abort(theReason);
@@ -259,7 +259,7 @@ describe('ReactDOMFizzStaticNode', () => {
259259
},
260260
);
261261

262-
await jest.runOnlyPendingTimers();
262+
await jest.runAllTimers();
263263

264264
const theReason = new Error('aborted for reasons');
265265
controller.abort(theReason);
@@ -422,7 +422,7 @@ describe('ReactDOMFizzStaticNode', () => {
422422
},
423423
});
424424

425-
await jest.runOnlyPendingTimers();
425+
await jest.runAllTimers();
426426

427427
controller.abort('foobar');
428428

@@ -464,7 +464,7 @@ describe('ReactDOMFizzStaticNode', () => {
464464
},
465465
});
466466

467-
await jest.runOnlyPendingTimers();
467+
await jest.runAllTimers();
468468

469469
controller.abort(new Error('uh oh'));
470470

0 commit comments

Comments
 (0)