Skip to content

Commit f411e89

Browse files
authored
Remote .internal override from untrusted URL tests (#26372)
Adding `.internal` to a test file prevents it from being tested in build mode. The best practice is to instead gate the test based on whether the feature is enabled. Ideally we'd use the `@gate` pragma in these tests, but the `itRenders` test helpers don't support that.
1 parent 6334614 commit f411e89

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.internal.js renamed to packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ function runTests(itRenders, itRejectsRendering, expectToReject) {
149149
}
150150

151151
describe('ReactDOMServerIntegration - Untrusted URLs', () => {
152+
// The `itRenders` helpers don't work with the gate pragma, so we have to do
153+
// this instead.
154+
if (gate(flags => flags.disableJavaScriptURLs)) {
155+
it("empty test so Jest doesn't complain", () => {});
156+
return;
157+
}
158+
152159
function initModules() {
153160
jest.resetModules();
154161
React = require('react');
@@ -181,6 +188,13 @@ describe('ReactDOMServerIntegration - Untrusted URLs', () => {
181188
});
182189

183190
describe('ReactDOMServerIntegration - Untrusted URLs - disableJavaScriptURLs', () => {
191+
// The `itRenders` helpers don't work with the gate pragma, so we have to do
192+
// this instead.
193+
if (gate(flags => !flags.disableJavaScriptURLs)) {
194+
it("empty test so Jest doesn't complain", () => {});
195+
return;
196+
}
197+
184198
function initModules() {
185199
jest.resetModules();
186200
const ReactFeatureFlags = require('shared/ReactFeatureFlags');

scripts/jest/setupTests.www.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ jest.mock('shared/ReactFeatureFlags', () => {
66
() => jest.requireActual('shared/forks/ReactFeatureFlags.www-dynamic'),
77
{virtual: true}
88
);
9-
10-
const wwwFlags = jest.requireActual('shared/forks/ReactFeatureFlags.www');
11-
const defaultFlags = jest.requireActual('shared/ReactFeatureFlags');
12-
13-
// TODO: Many tests were written before we started running them against the
14-
// www configuration. Update those tests so that they work against the www
15-
// configuration, too. Then remove these overrides.
16-
wwwFlags.disableJavaScriptURLs = defaultFlags.disableJavaScriptURLs;
17-
18-
return wwwFlags;
9+
return jest.requireActual('shared/forks/ReactFeatureFlags.www');
1910
});
2011

2112
jest.mock('scheduler/src/SchedulerFeatureFlags', () => {

0 commit comments

Comments
 (0)