diff --git a/.eslintrc.js b/.eslintrc.js
index b10d30525c1..8ad6dddf9a3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -171,6 +171,7 @@ module.exports = {
__PROFILE__: true,
__UMD__: true,
__EXPERIMENTAL__: true,
+ __TESTING__: true,
trustedTypes: true,
},
};
diff --git a/fixtures/dom/src/__tests__/nested-act-test.js b/fixtures/dom/src/__tests__/nested-act-test.js
index 4a39a0ea98f..c07eb5d5335 100644
--- a/fixtures/dom/src/__tests__/nested-act-test.js
+++ b/fixtures/dom/src/__tests__/nested-act-test.js
@@ -15,12 +15,15 @@ let TestAct;
global.__DEV__ = process.env.NODE_ENV !== 'production';
expect.extend(require('../toWarnDev'));
+jest.mock('react-dom', () =>
+ require.requireActual('react-dom/unstable-testing')
+);
describe('unmocked scheduler', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
- DOMAct = require('react-dom/test-utils').act;
+ DOMAct = require('react-dom').act;
TestRenderer = require('react-test-renderer');
TestAct = TestRenderer.act;
});
diff --git a/fixtures/dom/src/__tests__/wrong-act-test.js b/fixtures/dom/src/__tests__/wrong-act-test.js
index 38029be9b9c..8df6ec7b7c9 100644
--- a/fixtures/dom/src/__tests__/wrong-act-test.js
+++ b/fixtures/dom/src/__tests__/wrong-act-test.js
@@ -10,7 +10,6 @@
let React;
let ReactDOM;
let ReactART;
-let TestUtils;
let ARTSVGMode;
let ARTCurrentMode;
let TestRenderer;
@@ -20,6 +19,9 @@ global.__DEV__ = process.env.NODE_ENV !== 'production';
global.__EXPERIMENTAL__ = process.env.RELEASE_CHANNEL === 'experimental';
expect.extend(require('../toWarnDev'));
+jest.mock('react-dom', () =>
+ require.requireActual('react-dom/unstable-testing')
+);
function App(props) {
return 'hello world';
@@ -29,7 +31,6 @@ beforeEach(() => {
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
- TestUtils = require('react-dom/test-utils');
ReactART = require('react-art');
ARTSVGMode = require('art/modes/svg');
ARTCurrentMode = require('art/modes/current');
@@ -70,7 +71,7 @@ beforeEach(() => {
});
it("doesn't warn when you use the right act + renderer: dom", () => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
ReactDOM.render(, document.createElement('div'));
});
});
@@ -86,7 +87,7 @@ it('resets correctly across renderers', () => {
React.useEffect(() => {}, []);
return null;
}
- TestUtils.act(() => {
+ ReactDOM.act(() => {
TestRenderer.act(() => {});
expect(() => {
TestRenderer.create();
@@ -123,7 +124,7 @@ it('warns when using the wrong act version - test + dom: updates', () => {
it('warns when using the wrong act version - dom + test: .create()', () => {
expect(() => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
TestRenderer.create();
});
}).toWarnDev(["It looks like you're using the wrong act()"], {
@@ -134,7 +135,7 @@ it('warns when using the wrong act version - dom + test: .create()', () => {
it('warns when using the wrong act version - dom + test: .update()', () => {
const root = TestRenderer.create();
expect(() => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
root.update();
});
}).toWarnDev(["It looks like you're using the wrong act()"], {
@@ -151,14 +152,14 @@ it('warns when using the wrong act version - dom + test: updates', () => {
}
TestRenderer.create();
expect(() => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
setCtr(1);
});
}).toWarnDev(["It looks like you're using the wrong act()"]);
});
it('does not warn when nesting react-act inside react-dom', () => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
ReactDOM.render(, document.createElement('div'));
});
});
@@ -171,7 +172,7 @@ it('does not warn when nesting react-act inside react-test-renderer', () => {
it("doesn't warn if you use nested acts from different renderers", () => {
TestRenderer.act(() => {
- TestUtils.act(() => {
+ ReactDOM.act(() => {
TestRenderer.create();
});
});
diff --git a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
index 7f1c461d935..d29beb3d250 100644
--- a/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
+++ b/packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js
@@ -12,6 +12,10 @@ import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Comp
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type Store from 'react-devtools-shared/src/devtools/store';
+// unmock the testing builds
+jest.unmock('react');
+jest.unmock('react-dom');
+
describe('InspectedElementContext', () => {
let React;
let ReactDOM;
diff --git a/packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js b/packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js
index fb677852136..f5226951df7 100644
--- a/packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js
+++ b/packages/react-devtools-shared/src/__tests__/legacy/storeLegacy-v15-test.js
@@ -7,6 +7,10 @@
* @flow
*/
+// unmock the testing builds
+jest.unmock('react');
+jest.unmock('react-dom');
+
describe('Store (legacy)', () => {
let React;
let ReactDOM;
diff --git a/packages/react-dom/npm/testing.js b/packages/react-dom/npm/testing.js
deleted file mode 100644
index 0cb587bf9a9..00000000000
--- a/packages/react-dom/npm/testing.js
+++ /dev/null
@@ -1,38 +0,0 @@
-'use strict';
-
-function checkDCE() {
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
- if (
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
- ) {
- return;
- }
- if (process.env.NODE_ENV !== 'production') {
- // This branch is unreachable because this function is only called
- // in production, but the condition is true only in development.
- // Therefore if the branch is still here, dead code elimination wasn't
- // properly applied.
- // Don't change the message. React DevTools relies on it. Also make sure
- // this message doesn't occur elsewhere in this function, or it will cause
- // a false positive.
- throw new Error('^_^');
- }
- try {
- // Verify that the code above has been dead code eliminated (DCE'd).
- __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
- } catch (err) {
- // DevTools shouldn't crash React, no matter what.
- // We should still report in case we break this code.
- console.error(err);
- }
-}
-
-if (process.env.NODE_ENV === 'production') {
- // DCE check should happen before ReactDOM bundle executes so that
- // DevTools can report bad minification during injection.
- checkDCE();
- module.exports = require('./cjs/react-dom-testing.production.min.js');
-} else {
- module.exports = require('./cjs/react-dom-testing.development.js');
-}
diff --git a/packages/react-dom/npm/unstable-testing.js b/packages/react-dom/npm/unstable-testing.js
new file mode 100644
index 00000000000..7185d893ba5
--- /dev/null
+++ b/packages/react-dom/npm/unstable-testing.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (process.env.NODE_ENV === 'production') {
+ module.exports = require('./cjs/react-dom-unstable-testing.production.min.js');
+} else {
+ module.exports = require('./cjs/react-dom-unstable-testing.development.js');
+}
diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json
index fb5f49740ca..4acf66e9c94 100644
--- a/packages/react-dom/package.json
+++ b/packages/react-dom/package.json
@@ -39,6 +39,7 @@
"unstable-fizz.browser.js",
"unstable-fizz.node.js",
"unstable-native-dependencies.js",
+ "unstable-testing.js",
"cjs/",
"umd/"
],
diff --git a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
index 2f142597350..20fef141663 100644
--- a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
+++ b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
@@ -9,7 +9,6 @@
let React;
let ReactDOM;
-let ReactTestUtils;
let SchedulerTracing;
let Scheduler;
let act;
@@ -25,7 +24,7 @@ function sleep(period) {
});
}
-describe('ReactTestUtils.act()', () => {
+describe('act()', () => {
// first we run all the tests with concurrent mode
if (__EXPERIMENTAL__) {
let concurrentRoot = null;
@@ -155,10 +154,9 @@ function runActTests(label, render, unmount, rerender) {
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
- ReactTestUtils = require('react-dom/test-utils');
SchedulerTracing = require('scheduler/tracing');
Scheduler = require('scheduler');
- act = ReactTestUtils.act;
+ act = ReactDOM.act;
container = document.createElement('div');
document.body.appendChild(container);
});
@@ -721,7 +719,7 @@ function runActTests(label, render, unmount, rerender) {
});
describe('suspense', () => {
- if (__DEV__ && __EXPERIMENTAL__) {
+ if (__EXPERIMENTAL__) {
// todo - remove __DEV__ check once we start using testing builds
it('triggers fallbacks if available', async () => {
let resolved = false;
@@ -792,7 +790,7 @@ function runActTests(label, render, unmount, rerender) {
}
});
describe('warn in prod mode', () => {
- it('warns if you try to use act() in prod mode', () => {
+ xit('warns if you try to use act() in prod mode', () => {
const spy = spyOnDevAndProd(console, 'error');
act(() => {});
diff --git a/packages/react-dom/testing.classic.fb.js b/packages/react-dom/unstable-testing.classic.fb.js
similarity index 100%
rename from packages/react-dom/testing.classic.fb.js
rename to packages/react-dom/unstable-testing.classic.fb.js
diff --git a/packages/react-dom/testing.experimental.js b/packages/react-dom/unstable-testing.experimental.js
similarity index 100%
rename from packages/react-dom/testing.experimental.js
rename to packages/react-dom/unstable-testing.experimental.js
diff --git a/packages/react-dom/testing.js b/packages/react-dom/unstable-testing.js
similarity index 100%
rename from packages/react-dom/testing.js
rename to packages/react-dom/unstable-testing.js
diff --git a/packages/react-dom/testing.modern.fb.js b/packages/react-dom/unstable-testing.modern.fb.js
similarity index 100%
rename from packages/react-dom/testing.modern.fb.js
rename to packages/react-dom/unstable-testing.modern.fb.js
diff --git a/packages/react-dom/testing.stable.js b/packages/react-dom/unstable-testing.stable.js
similarity index 100%
rename from packages/react-dom/testing.stable.js
rename to packages/react-dom/unstable-testing.stable.js
diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index 851e22f8fe8..ffca19d07fc 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -962,7 +962,7 @@ function mountEffect(
): void {
if (__DEV__) {
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ('undefined' !== typeof jest) {
+ if (__TESTING__ || 'undefined' !== typeof jest) {
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber);
}
}
@@ -980,7 +980,7 @@ function updateEffect(
): void {
if (__DEV__) {
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ('undefined' !== typeof jest) {
+ if (__TESTING__ || 'undefined' !== typeof jest) {
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber);
}
}
@@ -1360,7 +1360,7 @@ function dispatchAction(
}
if (__DEV__) {
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ('undefined' !== typeof jest) {
+ if (__TESTING__ || 'undefined' !== typeof jest) {
warnIfNotScopedWithMatchingAct(fiber);
warnIfNotCurrentlyActingUpdatesInDev(fiber);
}
diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js
index 816a3946562..d7d1d576074 100644
--- a/packages/react-reconciler/src/ReactFiberReconciler.js
+++ b/packages/react-reconciler/src/ReactFiberReconciler.js
@@ -87,10 +87,10 @@ import {
findHostInstancesForRefresh,
} from './ReactFiberHotReloading';
-// used by isTestEnvironment builds
+// used by __TESTING__ builds
import enqueueTask from 'shared/enqueueTask';
import * as Scheduler from 'scheduler';
-// end isTestEnvironment imports
+// end __TESTING__ imports
type OpaqueRoot = FiberRoot;
@@ -238,7 +238,7 @@ export function updateContainer(
const currentTime = requestCurrentTimeForUpdate();
if (__DEV__) {
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if ('undefined' !== typeof jest) {
+ if (__TESTING__ || 'undefined' !== typeof jest) {
warnIfUnmockedScheduler(current);
warnIfNotScopedWithMatchingAct(current);
}
diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js
index 8850e8532f9..6be16db7e16 100644
--- a/packages/react-reconciler/src/ReactFiberWorkLoop.js
+++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js
@@ -789,7 +789,7 @@ function finishConcurrentRender(
hasNotProcessedNewUpdates &&
// do not delay if we're inside an act() scope
!(
- __DEV__ &&
+ (__DEV__ || __TESTING__) &&
flushSuspenseFallbacksInTests &&
IsThisRendererActing.current
)
@@ -855,7 +855,7 @@ function finishConcurrentRender(
if (
// do not delay if we're inside an act() scope
!(
- __DEV__ &&
+ (__DEV__ || __TESTING__) &&
flushSuspenseFallbacksInTests &&
IsThisRendererActing.current
)
@@ -946,7 +946,7 @@ function finishConcurrentRender(
if (
// do not delay if we're inside an act() scope
!(
- __DEV__ &&
+ (__DEV__ || __TESTING__) &&
flushSuspenseFallbacksInTests &&
IsThisRendererActing.current
) &&
@@ -2815,7 +2815,9 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) {
}
// a 'shared' variable that changes when act() opens/closes in tests.
-export const IsThisRendererActing = {current: (false: boolean)};
+// $FlowExpectedError avoids a shape check on IsThisRendererActing
+export const IsThisRendererActing: {current: boolean} =
+ __DEV__ || __TESTING__ ? {current: false} : null;
export function warnIfNotScopedWithMatchingAct(fiber: Fiber): void {
if (__DEV__) {
diff --git a/packages/react/npm/unstable-testing.js b/packages/react/npm/unstable-testing.js
new file mode 100644
index 00000000000..a5faa746126
--- /dev/null
+++ b/packages/react/npm/unstable-testing.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (process.env.NODE_ENV === 'production') {
+ module.exports = require('./cjs/react-unstable-testing.production.min.js');
+} else {
+ module.exports = require('./cjs/react-unstable-testing.development.js');
+}
diff --git a/packages/react/package.json b/packages/react/package.json
index 2ffa23333ad..57876e9992a 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -13,6 +13,7 @@
"README.md",
"build-info.json",
"index.js",
+ "unstable-testing.js",
"cjs/",
"umd/"
],
diff --git a/packages/react/src/ReactSharedInternals.js b/packages/react/src/ReactSharedInternals.js
index 9209a86a954..310e65d4c23 100644
--- a/packages/react/src/ReactSharedInternals.js
+++ b/packages/react/src/ReactSharedInternals.js
@@ -16,7 +16,6 @@ const ReactSharedInternals = {
ReactCurrentDispatcher,
ReactCurrentBatchConfig,
ReactCurrentOwner,
- IsSomeRendererActing,
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
assign,
};
@@ -31,4 +30,8 @@ if (__DEV__) {
});
}
+if (__DEV__ || __TESTING__) {
+ ReactSharedInternals.IsSomeRendererActing = IsSomeRendererActing;
+}
+
export default ReactSharedInternals;
diff --git a/packages/react/unstable-testing.classic.fb.js b/packages/react/unstable-testing.classic.fb.js
new file mode 100644
index 00000000000..e5680f38868
--- /dev/null
+++ b/packages/react/unstable-testing.classic.fb.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export * from './index.classic.fb';
diff --git a/packages/react/unstable-testing.experimental.js b/packages/react/unstable-testing.experimental.js
new file mode 100644
index 00000000000..73f4855433e
--- /dev/null
+++ b/packages/react/unstable-testing.experimental.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export * from './index.experimental';
diff --git a/packages/react/unstable-testing.js b/packages/react/unstable-testing.js
new file mode 100644
index 00000000000..58a149acca9
--- /dev/null
+++ b/packages/react/unstable-testing.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export * from './index';
diff --git a/packages/react/unstable-testing.modern.fb.js b/packages/react/unstable-testing.modern.fb.js
new file mode 100644
index 00000000000..287fc1c9df7
--- /dev/null
+++ b/packages/react/unstable-testing.modern.fb.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export * from './index.modern.fb';
diff --git a/packages/react/unstable-testing.stable.js b/packages/react/unstable-testing.stable.js
new file mode 100644
index 00000000000..de6c413e860
--- /dev/null
+++ b/packages/react/unstable-testing.stable.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export * from './index.stable';
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js
deleted file mode 100644
index c8e7e724841..00000000000
--- a/packages/shared/forks/ReactFeatureFlags.testing.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import invariant from 'shared/invariant';
-
-import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
-import typeof * as ExportsType from './ReactFeatureFlags.testing';
-
-export const debugRenderPhaseSideEffectsForStrictMode = false;
-export const enableUserTimingAPI = __DEV__;
-export const warnAboutDeprecatedLifecycles = true;
-export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
-export const enableProfilerTimer = __PROFILE__;
-export const enableSchedulerTracing = __PROFILE__;
-export const enableSuspenseServerRenderer = false;
-export const enableSelectiveHydration = false;
-export const enableBlocksAPI = false;
-export const disableJavaScriptURLs = false;
-export const disableInputAttributeSyncing = false;
-export const warnAboutShorthandPropertyCollision = true;
-export const enableSchedulerDebugging = false;
-export const enableDeprecatedFlareAPI = false;
-export const enableFundamentalAPI = false;
-export const enableScopeAPI = false;
-export const warnAboutUnmockedScheduler = false;
-export const flushSuspenseFallbacksInTests = true;
-export const enableSuspenseCallback = false;
-export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
-export const disableLegacyContext = false;
-export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
-export const enableTrustedTypesIntegration = false;
-export const disableTextareaChildren = false;
-export const disableMapsAsChildren = false;
-export const warnUnstableRenderSubtreeIntoContainer = false;
-export const deferPassiveEffectCleanupDuringUnmount = false;
-export const runAllPassiveEffectDestroysBeforeCreates = false;
-export const enableModernEventSystem = false;
-export const warnAboutSpreadingKeyToJSX = false;
-
-// Internal-only attempt to debug a React Native issue. See D20130868.
-export const throwEarlyForMysteriousError = false;
-
-// Only used in www builds.
-export function addUserTimingListener() {
- invariant(false, 'Not implemented.');
-}
-
-// Flow magic to verify the exports of this file match the original version.
-// eslint-disable-next-line no-unused-vars
-type Check<_X, Y: _X, X: Y = _X> = null;
-// eslint-disable-next-line no-unused-expressions
-(null: Check);
diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js
deleted file mode 100644
index 4b4db206546..00000000000
--- a/packages/shared/forks/ReactFeatureFlags.testing.www.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-import invariant from 'shared/invariant';
-
-import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
-import typeof * as ExportsType from './ReactFeatureFlags.testing.www';
-
-export const debugRenderPhaseSideEffectsForStrictMode = false;
-export const enableUserTimingAPI = false;
-export const warnAboutDeprecatedLifecycles = true;
-export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
-export const enableProfilerTimer = false;
-export const enableSchedulerTracing = false;
-export const enableSuspenseServerRenderer = true;
-export const enableSelectiveHydration = true;
-export const enableBlocksAPI = true;
-export const disableJavaScriptURLs = true;
-export const disableInputAttributeSyncing = false;
-export const warnAboutShorthandPropertyCollision = true;
-export const enableSchedulerDebugging = false;
-export const enableDeprecatedFlareAPI = true;
-export const enableFundamentalAPI = false;
-export const enableScopeAPI = true;
-export const warnAboutUnmockedScheduler = true;
-export const flushSuspenseFallbacksInTests = true;
-export const enableSuspenseCallback = true;
-export const warnAboutDefaultPropsOnFunctionComponents = false;
-export const warnAboutStringRefs = false;
-export const disableLegacyContext = __EXPERIMENTAL__;
-export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
-export const enableTrustedTypesIntegration = false;
-export const disableTextareaChildren = __EXPERIMENTAL__;
-export const disableMapsAsChildren = __EXPERIMENTAL__;
-export const warnUnstableRenderSubtreeIntoContainer = false;
-export const deferPassiveEffectCleanupDuringUnmount = false;
-export const runAllPassiveEffectDestroysBeforeCreates = false;
-export const enableModernEventSystem = false;
-export const warnAboutSpreadingKeyToJSX = false;
-
-// Internal-only attempt to debug a React Native issue. See D20130868.
-export const throwEarlyForMysteriousError = false;
-
-// Only used in www builds.
-export function addUserTimingListener() {
- invariant(false, 'Not implemented.');
-}
-
-// Flow magic to verify the exports of this file match the original version.
-// eslint-disable-next-line no-unused-vars
-type Check<_X, Y: _X, X: Y = _X> = null;
-// eslint-disable-next-line no-unused-expressions
-(null: Check);
diff --git a/scripts/flow/environment.js b/scripts/flow/environment.js
index 524cae905bc..861fb18a367 100644
--- a/scripts/flow/environment.js
+++ b/scripts/flow/environment.js
@@ -12,6 +12,7 @@
declare var __PROFILE__: boolean;
declare var __UMD__: boolean;
declare var __EXPERIMENTAL__: boolean;
+declare var __TESTING__: boolean;
declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
inject: ?((stuff: Object) => void)
diff --git a/scripts/jest/config.source-persistent.js b/scripts/jest/config.source-persistent.js
index 63c95c5584b..30213b3143b 100644
--- a/scripts/jest/config.source-persistent.js
+++ b/scripts/jest/config.source-persistent.js
@@ -16,10 +16,10 @@ const preferredExtension = __EXPERIMENTAL__ ? '.js' : '.stable.js';
const moduleNameMapper = {};
moduleNameMapper[
'^react$'
-] = `/packages/react/index${preferredExtension}`;
+] = `/packages/react/unstable-testing${preferredExtension}`;
moduleNameMapper[
'^react-dom$'
-] = `/packages/react-dom/index${preferredExtension}`;
+] = `/packages/react-dom/unstable-testing${preferredExtension}`;
module.exports = Object.assign({}, baseConfig, {
// Prefer the stable forks for tests.
diff --git a/scripts/jest/config.source.js b/scripts/jest/config.source.js
index 18f44e3b721..3f0ac42452d 100644
--- a/scripts/jest/config.source.js
+++ b/scripts/jest/config.source.js
@@ -16,10 +16,10 @@ const preferredExtension = __EXPERIMENTAL__ ? '.js' : '.stable.js';
const moduleNameMapper = {};
moduleNameMapper[
'^react$'
-] = `/packages/react/index${preferredExtension}`;
+] = `/packages/react/unstable-testing${preferredExtension}`;
moduleNameMapper[
'^react-dom$'
-] = `/packages/react-dom/index${preferredExtension}`;
+] = `/packages/react-dom/unstable-testing${preferredExtension}`;
module.exports = Object.assign({}, baseConfig, {
// Prefer the stable forks for tests.
diff --git a/scripts/jest/setupEnvironment.js b/scripts/jest/setupEnvironment.js
index 7eef6432e73..dd99faa27dc 100644
--- a/scripts/jest/setupEnvironment.js
+++ b/scripts/jest/setupEnvironment.js
@@ -7,6 +7,7 @@ if (NODE_ENV !== 'development' && NODE_ENV !== 'production') {
global.__DEV__ = NODE_ENV === 'development';
global.__PROFILE__ = NODE_ENV === 'development';
global.__UMD__ = false;
+global.__TESTING__ = true;
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
diff --git a/scripts/jest/setupTests.build.js b/scripts/jest/setupTests.build.js
index 62db0fc007f..7af801ed071 100644
--- a/scripts/jest/setupTests.build.js
+++ b/scripts/jest/setupTests.build.js
@@ -4,3 +4,7 @@ jest.mock('scheduler', () => require.requireActual('scheduler/unstable_mock'));
jest.mock('scheduler/src/SchedulerHostConfig', () =>
require.requireActual('scheduler/src/forks/SchedulerHostConfig.mock.js')
);
+jest.mock('react', () => require.requireActual(`react/unstable-testing`));
+jest.mock('react-dom', () =>
+ require.requireActual(`react-dom/unstable-testing`)
+);
diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js
index c3e7d8c7c73..9496de85924 100644
--- a/scripts/rollup/build.js
+++ b/scripts/rollup/build.js
@@ -345,6 +345,9 @@ function getPlugins(
bundleType === RN_FB_DEV ||
bundleType === RN_FB_PROD ||
bundleType === RN_FB_PROFILING;
+ const isTestBundle =
+ entry === 'react-dom/unstable-testing' ||
+ entry === 'react/unstable-testing';
const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;
return [
// Extract error codes from invariant() messages into a file.
@@ -389,6 +392,7 @@ function getPlugins(
__DEV__: isProduction ? 'false' : 'true',
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
+ __TESTING__: isTestBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
__EXPERIMENTAL__,
}),
diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js
index 41b9e30b43a..317d3faeaaa 100644
--- a/scripts/rollup/bundles.js
+++ b/scripts/rollup/bundles.js
@@ -76,6 +76,24 @@ const bundles = [
externals: [],
},
+ /******* Isomorphic - Testing *******/
+ {
+ bundleTypes: [UMD_DEV, UMD_PROD, UMD_PROFILING, NODE_DEV, NODE_PROD],
+ moduleType: ISOMORPHIC,
+ entry: 'react/unstable-testing',
+ global: 'React',
+ externals: [],
+ },
+
+ /******* Isomorphic - www - Testing *******/
+ {
+ bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING],
+ moduleType: ISOMORPHIC,
+ entry: 'react/unstable-testing',
+ global: 'ReactTesting',
+ externals: [],
+ },
+
/******* React DOM *******/
{
bundleTypes: [
@@ -95,24 +113,41 @@ const bundles = [
externals: ['react'],
},
- /******* Test Utils *******/
+ /******* React DOM - Testing *******/
+
{
- moduleType: RENDERER_UTILS,
- bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
- entry: 'react-dom/test-utils',
- global: 'ReactTestUtils',
- externals: ['react', 'react-dom'],
+ moduleType: RENDERER,
+ bundleTypes: [
+ UMD_DEV,
+ UMD_PROD,
+ UMD_PROFILING,
+ NODE_DEV,
+ NODE_PROD,
+ NODE_PROFILING,
+ ],
+ entry: 'react-dom/unstable-testing',
+ global: 'ReactDOM',
+ externals: ['react'],
},
/******* React DOM - www - Testing *******/
{
moduleType: RENDERER,
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING],
- entry: 'react-dom/testing',
+ entry: 'react-dom/unstable-testing',
global: 'ReactDOMTesting',
externals: ['react'],
},
+ /******* Test Utils *******/
+ {
+ moduleType: RENDERER_UTILS,
+ bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
+ entry: 'react-dom/test-utils',
+ global: 'ReactTestUtils',
+ externals: ['react', 'react-dom'],
+ },
+
/* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
{
bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD],
diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js
index 1fbbd0ffed8..c1f9a12e379 100644
--- a/scripts/rollup/forks.js
+++ b/scripts/rollup/forks.js
@@ -34,7 +34,7 @@ const forks = Object.freeze({
// happens. Other bundles just require('object-assign') anyway.
return null;
}
- if (entry === 'react') {
+ if (entry === 'react' || entry === 'react/unstable-testing') {
// Use the forked version that uses ES modules instead of CommonJS.
return 'shared/forks/object-assign.inline-umd.js';
}
@@ -50,7 +50,7 @@ const forks = Object.freeze({
// Without this fork, importing `shared/ReactSharedInternals` inside
// the `react` package itself would not work due to a cyclical dependency.
'shared/ReactSharedInternals': (bundleType, entry, dependencies) => {
- if (entry === 'react') {
+ if (entry === 'react' || entry === 'react/unstable-testing') {
return 'react/src/ReactSharedInternals';
}
if (dependencies.indexOf('react') === -1) {
@@ -110,14 +110,6 @@ const forks = Object.freeze({
return 'shared/forks/ReactFeatureFlags.test-renderer.www.js';
}
return 'shared/forks/ReactFeatureFlags.test-renderer.js';
- case 'react-dom/testing':
- switch (bundleType) {
- case FB_WWW_DEV:
- case FB_WWW_PROD:
- case FB_WWW_PROFILING:
- return 'shared/forks/ReactFeatureFlags.testing.www.js';
- }
- return 'shared/forks/ReactFeatureFlags.testing.js';
default:
switch (bundleType) {
case FB_WWW_DEV:
diff --git a/scripts/shared/inlinedHostConfigs.js b/scripts/shared/inlinedHostConfigs.js
index c92deb2f24f..e800b046a1d 100644
--- a/scripts/shared/inlinedHostConfigs.js
+++ b/scripts/shared/inlinedHostConfigs.js
@@ -11,7 +11,7 @@ module.exports = [
shortName: 'dom',
entryPoints: [
'react-dom',
- 'react-dom/testing',
+ 'react-dom/unstable-testing',
'react-dom/unstable-fizz.node',
'react-flight-dom-webpack/server.node',
'react-flight-dom-webpack',