Skip to content

Commit 3fb1d4a

Browse files
committed
Don't reset the cache twice in DOMServerIntegration tests
We used to do this to simulate testing separate bundles. But now we actually *do* test bundles. So there is no need for this, as it makes tests slower.
1 parent 96ccaf1 commit 3fb1d4a

8 files changed

+7
-81
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,11 @@ let React;
1515
let ReactDOM;
1616
let ReactDOMServer;
1717

18-
// When there is a test that renders on server and then on client and expects a logged
19-
// error, you want to see the error show up both on server and client. Unfortunately,
20-
// React refuses to issue the same error twice to avoid clogging up the console.
21-
// To get around this, we must reload React modules in between server and client render.
2218
function initModules() {
23-
// First, reset the modules to load the client renderer.
19+
// Reset warning cache.
2420
jest.resetModuleRegistry();
2521
React = require('react');
2622
ReactDOM = require('react-dom');
27-
28-
// Now we reset the modules again to load the server renderer.
29-
// Resetting is important because we want to avoid any shared state
30-
// influencing the tests.
31-
jest.resetModuleRegistry();
3223
ReactDOMServer = require('react-dom/server');
3324

3425
// Make them available to the helpers.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,11 @@ let React;
1717
let ReactDOM;
1818
let ReactDOMServer;
1919

20-
// When there is a test that renders on server and then on client and expects a logged
21-
// error, you want to see the error show up both on server and client. Unfortunately,
22-
// React refuses to issue the same error twice to avoid clogging up the console.
23-
// To get around this, we must reload React modules in between server and client render.
2420
function initModules() {
25-
// First, reset the modules to load the client renderer.
21+
// Reset warning cache.
2622
jest.resetModuleRegistry();
2723
React = require('react');
2824
ReactDOM = require('react-dom');
29-
30-
// Now we reset the modules again to load the server renderer.
31-
// Resetting is important because we want to avoid any shared state
32-
// influencing the tests.
33-
jest.resetModuleRegistry();
3425
ReactDOMServer = require('react-dom/server');
3526

3627
// Make them available to the helpers.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ let React;
1616
let ReactDOM;
1717
let ReactDOMServer;
1818

19-
// When there is a test that renders on server and then on client and expects a logged
20-
// error, you want to see the error show up both on server and client. Unfortunately,
21-
// React refuses to issue the same error twice to avoid clogging up the console.
22-
// To get around this, we must reload React modules in between server and client render.
2319
function initModules() {
24-
// First, reset the modules to load the client renderer.
20+
// Reset warning cache.
2521
jest.resetModuleRegistry();
2622
PropTypes = require('prop-types');
2723
React = require('react');
2824
ReactDOM = require('react-dom');
29-
30-
// Now we reset the modules again to load the server renderer.
31-
// Resetting is important because we want to avoid any shared state
32-
// influencing the tests.
33-
jest.resetModuleRegistry();
3425
ReactDOMServer = require('react-dom/server');
3526

3627
// Make them available to the helpers.

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,10 @@ let React;
1717
let ReactDOM;
1818
let ReactDOMServer;
1919

20-
// When there is a test that renders on server and then on client and expects a logged
21-
// error, you want to see the error show up both on server and client. Unfortunately,
22-
// React refuses to issue the same error twice to avoid clogging up the console.
23-
// To get around this, we must reload React modules in between server and client render.
2420
function initModules() {
25-
// First, reset the modules to load the client renderer.
2621
jest.resetModuleRegistry();
2722
React = require('react');
2823
ReactDOM = require('react-dom');
29-
30-
// Now we reset the modules again to load the server renderer.
31-
// Resetting is important because we want to avoid any shared state
32-
// influencing the tests.
33-
jest.resetModuleRegistry();
3424
ReactDOMServer = require('react-dom/server');
3525

3626
// Make them available to the helpers.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ let ReactDOM;
1616
let ReactDOMServer;
1717
let ReactTestUtils;
1818

19-
// When there is a test that renders on server and then on client and expects a logged
20-
// error, you want to see the error show up both on server and client. Unfortunately,
21-
// React refuses to issue the same error twice to avoid clogging up the console.
22-
// To get around this, we must reload React modules in between server and client render.
2319
function initModules() {
24-
// First, reset the modules to load the client renderer.
20+
// Reset warning cache.
2521
jest.resetModuleRegistry();
2622
React = require('react');
2723
ReactDOM = require('react-dom');
2824
ReactTestUtils = require('react-dom/test-utils');
29-
30-
// Now we reset the modules again to load the server renderer.
31-
// Resetting is important because we want to avoid any shared state
32-
// influencing the tests.
33-
jest.resetModuleRegistry();
3425
ReactDOMServer = require('react-dom/server');
3526

3627
// Make them available to the helpers.

packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.internal.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,12 @@ let React;
1515
let ReactDOM;
1616
let ReactDOMServer;
1717

18-
// When there is a test that renders on server and then on client and expects a logged
19-
// error, you want to see the error show up both on server and client. Unfortunately,
20-
// React refuses to issue the same error twice to avoid clogging up the console.
21-
// To get around this, we must reload React modules in between server and client render.
2218
function initModules() {
23-
// First, reset the modules to load the client renderer.
19+
// Reset warning cache.
2420
jest.resetModuleRegistry();
2521
require('shared/ReactFeatureFlags').enableReactFragment = true;
2622
React = require('react');
2723
ReactDOM = require('react-dom');
28-
29-
// Now we reset the modules again to load the server renderer.
30-
// Resetting is important because we want to avoid any shared state
31-
// influencing the tests.
32-
jest.resetModuleRegistry();
33-
require('shared/ReactFeatureFlags').enableReactFragment = true;
3424
ReactDOMServer = require('react-dom/server');
3525

3626
// Make them available to the helpers.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,12 @@ let React;
1515
let ReactDOM;
1616
let ReactDOMServer;
1717

18-
// When there is a test that renders on server and then on client and expects a logged
19-
// error, you want to see the error show up both on server and client. Unfortunately,
20-
// React refuses to issue the same error twice to avoid clogging up the console.
21-
// To get around this, we must reload React modules in between server and client render.
2218
function initModules() {
23-
// First, reset the modules to load the client renderer.
19+
// Reset warning cache.
2420
jest.resetModuleRegistry();
2521

2622
React = require('react');
2723
ReactDOM = require('react-dom');
28-
29-
// Now we reset the modules again to load the server renderer.
30-
// Resetting is important because we want to avoid any shared state
31-
// influencing the tests.
32-
jest.resetModuleRegistry();
3324
ReactDOMServer = require('react-dom/server');
3425

3526
// Make them available to the helpers.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,11 @@ let React;
1515
let ReactDOM;
1616
let ReactDOMServer;
1717

18-
// When there is a test that renders on server and then on client and expects a logged
19-
// error, you want to see the error show up both on server and client. Unfortunately,
20-
// React refuses to issue the same error twice to avoid clogging up the console.
21-
// To get around this, we must reload React modules in between server and client render.
2218
function initModules() {
23-
// First, reset the modules to load the client renderer.
19+
// Reset warning cache.
2420
jest.resetModuleRegistry();
2521
React = require('react');
2622
ReactDOM = require('react-dom');
27-
28-
// Now we reset the modules again to load the server renderer.
29-
// Resetting is important because we want to avoid any shared state
30-
// influencing the tests.
31-
jest.resetModuleRegistry();
3223
ReactDOMServer = require('react-dom/server');
3324

3425
// Make them available to the helpers.

0 commit comments

Comments
 (0)