[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.
Josh Story committed
Apr 9, 2024 at 11:50 UTC
67ff96e12df1e5da9a23668fbc21a5888021c523
3 files changed
+13
-4
packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
+3
-3
@@ -153,7 +153,7 @@ describe('ReactDOMFizzServer', () => {
153
});
154
155
renderOptions = {};
156
- if (gate(flags => flags.enableFizzExternalRuntime)) {
156
+ if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
157
renderOptions.unstable_externalRuntimeSrc =
158
'react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js';
159
}
@@ -610,7 +610,7 @@ describe('ReactDOMFizzServer', () => {
610
Array.from(container.getElementsByTagName('script')).filter(
611
node => node.getAttribute('nonce') === CSPnonce,
612
).length,
613
- ).toEqual(6);
613
+ ).toEqual(gate(flags => flags.shouldUseFizzExternalRuntime) ? 6 : 5);
614
615
await act(() => {
616
resolve({default: Text});
@@ -4292,7 +4292,7 @@ describe('ReactDOMFizzServer', () => {
4292
);
4293
});
4294
4295
- // @gate enableFizzExternalRuntime
4295
+ // @gate shouldUseFizzExternalRuntime
4296
it('does not send script tags for SSR instructions when using the external runtime', async () => {
4297
function App() {
4298
return (
packages/react-dom/src/__tests__/ReactDOMFloat-test.js
+1
-1
@@ -97,7 +97,7 @@ describe('ReactDOMFloat', () => {
97
});
98
99
renderOptions = {};
100
- if (gate(flags => flags.enableFizzExternalRuntime)) {
100
+ if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
101
renderOptions.unstable_externalRuntimeSrc =
102
'react-dom/unstable_server-external-runtime';
103
}
scripts/jest/TestFlags.js
+9
@@ -83,6 +83,15 @@ function getTestFlags() {
83
enableSuspenseList: releaseChannel === 'experimental' || www,
84
enableLegacyHidden: www,
85
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
+
95
// This is used by useSyncExternalStoresShared-test.js to decide whether
96
// to test the shim or the native implementation of useSES.
97
// TODO: It's disabled when enableRefAsProp is on because the JSX