Skip to content

Commit 67ff96e

Browse files
authored
[Tests][Fizz] Test script runtime even when external runtime is available (#28794)
Previously if the external runtime was enabled Fizz tests would use it exclusively. However now that this flag is enabled for OSS and Meta builds this means we were no longer testing the inline script runtime. This changes the test flags to produce some runs where we test the inline script runtime and others where we test the external runtime the external runtime will be tested if the flag is enabled and * Meta Builds: variant is true * OSS Builds: experiemental is true this gives us decent coverage. long term we should probably bring variant to OSS builds since we will eventually want to test both modes even when the external runtime is stable.
1 parent 7f93cb4 commit 67ff96e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('ReactDOMFizzServer', () => {
153153
});
154154

155155
renderOptions = {};
156-
if (gate(flags => flags.enableFizzExternalRuntime)) {
156+
if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
157157
renderOptions.unstable_externalRuntimeSrc =
158158
'react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js';
159159
}
@@ -610,7 +610,7 @@ describe('ReactDOMFizzServer', () => {
610610
Array.from(container.getElementsByTagName('script')).filter(
611611
node => node.getAttribute('nonce') === CSPnonce,
612612
).length,
613-
).toEqual(6);
613+
).toEqual(gate(flags => flags.shouldUseFizzExternalRuntime) ? 6 : 5);
614614

615615
await act(() => {
616616
resolve({default: Text});
@@ -4292,7 +4292,7 @@ describe('ReactDOMFizzServer', () => {
42924292
);
42934293
});
42944294

4295-
// @gate enableFizzExternalRuntime
4295+
// @gate shouldUseFizzExternalRuntime
42964296
it('does not send script tags for SSR instructions when using the external runtime', async () => {
42974297
function App() {
42984298
return (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('ReactDOMFloat', () => {
9797
});
9898

9999
renderOptions = {};
100-
if (gate(flags => flags.enableFizzExternalRuntime)) {
100+
if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
101101
renderOptions.unstable_externalRuntimeSrc =
102102
'react-dom/unstable_server-external-runtime';
103103
}

scripts/jest/TestFlags.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ function getTestFlags() {
8383
enableSuspenseList: releaseChannel === 'experimental' || www,
8484
enableLegacyHidden: www,
8585

86+
// This flag is used to determine whether we should run Fizz tests using
87+
// the external runtime or the inline script runtime.
88+
// For Meta we use variant to gate the feature. For OSS we use experimental
89+
shouldUseFizzExternalRuntime: !featureFlags.enableFizzExternalRuntime
90+
? false
91+
: www
92+
? __VARIANT__
93+
: __EXPERIMENTAL__,
94+
8695
// This is used by useSyncExternalStoresShared-test.js to decide whether
8796
// to test the shim or the native implementation of useSES.
8897
// TODO: It's disabled when enableRefAsProp is on because the JSX

0 commit comments

Comments
 (0)