Skip to content

Commit

Permalink
[Tests][Fizz] Test script runtime even when external runtime is avail…
Browse files Browse the repository at this point in the history
…able (#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.
  • Loading branch information
gnoff authored Apr 9, 2024
1 parent 7f93cb4 commit 67ff96e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('ReactDOMFizzServer', () => {
});

renderOptions = {};
if (gate(flags => flags.enableFizzExternalRuntime)) {
if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
renderOptions.unstable_externalRuntimeSrc =
'react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js';
}
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('ReactDOMFizzServer', () => {
Array.from(container.getElementsByTagName('script')).filter(
node => node.getAttribute('nonce') === CSPnonce,
).length,
).toEqual(6);
).toEqual(gate(flags => flags.shouldUseFizzExternalRuntime) ? 6 : 5);

await act(() => {
resolve({default: Text});
Expand Down Expand Up @@ -4292,7 +4292,7 @@ describe('ReactDOMFizzServer', () => {
);
});

// @gate enableFizzExternalRuntime
// @gate shouldUseFizzExternalRuntime
it('does not send script tags for SSR instructions when using the external runtime', async () => {
function App() {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('ReactDOMFloat', () => {
});

renderOptions = {};
if (gate(flags => flags.enableFizzExternalRuntime)) {
if (gate(flags => flags.shouldUseFizzExternalRuntime)) {
renderOptions.unstable_externalRuntimeSrc =
'react-dom/unstable_server-external-runtime';
}
Expand Down
9 changes: 9 additions & 0 deletions scripts/jest/TestFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ function getTestFlags() {
enableSuspenseList: releaseChannel === 'experimental' || www,
enableLegacyHidden: www,

// This flag is used to determine whether we should run Fizz tests using
// the external runtime or the inline script runtime.
// For Meta we use variant to gate the feature. For OSS we use experimental
shouldUseFizzExternalRuntime: !featureFlags.enableFizzExternalRuntime
? false
: www
? __VARIANT__
: __EXPERIMENTAL__,

// This is used by useSyncExternalStoresShared-test.js to decide whether
// to test the shim or the native implementation of useSES.
// TODO: It's disabled when enableRefAsProp is on because the JSX
Expand Down

0 comments on commit 67ff96e

Please sign in to comment.