forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use testing builds for our own tests
Following up from facebook#17915 where we generated testing builds for `react-dom`, this PR uses those builds for our own tests. - fixes `ReactFeatureFlags.testing` to use all the default flags - changes `ReactFeatureFlags.readonly` to return `isTestEnvironment: true` (this might not strictly be needed) - with jest, mocks `react-dom` with the testing version, both for source and builds - uses `ReactDOM.act` in one of these tests to verify it actually works
- Loading branch information
1 parent
256d78d
commit 331ab49
Showing
16 changed files
with
264 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ReactDOMFB = require('./src/client/ReactDOMFB'); | ||
|
||
// TODO: decide on the top-level export form. | ||
// This is hacky but makes it work with both Rollup and Jest. | ||
module.exports = ReactDOMFB.default || ReactDOMFB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
/* | ||
SYNC WITH forks/ReactFeatureFlags.www.js | ||
except isTestEnvironment = true | ||
*/ | ||
|
||
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; | ||
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www'; | ||
|
||
// Re-export dynamic flags from the www version. | ||
export const { | ||
debugRenderPhaseSideEffectsForStrictMode, | ||
disableInputAttributeSyncing, | ||
enableTrustedTypesIntegration, | ||
deferPassiveEffectCleanupDuringUnmount, | ||
} = require('ReactFeatureFlags'); | ||
|
||
// In www, we have experimental support for gathering data | ||
// from User Timing API calls in production. By default, we | ||
// only emit performance.mark/measure calls in __DEV__. But if | ||
// somebody calls addUserTimingListener() which is exposed as an | ||
// experimental FB-only export, we call performance.mark/measure | ||
// as long as there is more than a single listener. | ||
export let enableUserTimingAPI = __DEV__; | ||
|
||
export const enableProfilerTimer = __PROFILE__; | ||
export const enableSchedulerTracing = __PROFILE__; | ||
export const enableSchedulerDebugging = true; | ||
|
||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false; | ||
export const warnAboutDeprecatedLifecycles = true; | ||
export const warnAboutShorthandPropertyCollision = false; | ||
export const disableLegacyContext = false; | ||
export const warnAboutStringRefs = false; | ||
export const warnAboutDefaultPropsOnFunctionComponents = false; | ||
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false; | ||
|
||
export const enableTrainModelFix = true; | ||
|
||
export const exposeConcurrentModeAPIs = __EXPERIMENTAL__; | ||
|
||
export const enableSuspenseServerRenderer = true; | ||
export const enableSelectiveHydration = true; | ||
|
||
export const enableChunksAPI = __EXPERIMENTAL__; | ||
|
||
export const disableJavaScriptURLs = true; | ||
|
||
let refCount = 0; | ||
export function addUserTimingListener() { | ||
if (__DEV__) { | ||
// Noop. | ||
return () => {}; | ||
} | ||
refCount++; | ||
updateFlagOutsideOfReactCallStack(); | ||
return () => { | ||
refCount--; | ||
updateFlagOutsideOfReactCallStack(); | ||
}; | ||
} | ||
|
||
// The flag is intentionally updated in a timeout. | ||
// We don't support toggling it during reconciliation or | ||
// commit since that would cause mismatching user timing API calls. | ||
let timeout = null; | ||
function updateFlagOutsideOfReactCallStack() { | ||
if (!timeout) { | ||
timeout = setTimeout(() => { | ||
timeout = null; | ||
enableUserTimingAPI = refCount > 0; | ||
}); | ||
} | ||
} | ||
|
||
export const enableDeprecatedFlareAPI = true; | ||
|
||
export const enableFundamentalAPI = false; | ||
|
||
export const enableScopeAPI = true; | ||
|
||
export const enableJSXTransformAPI = true; | ||
|
||
export const warnAboutUnmockedScheduler = true; | ||
|
||
export const enableSuspenseCallback = true; | ||
|
||
export const flushSuspenseFallbacksInTests = true; | ||
|
||
export const enableNativeTargetAsInstance = false; | ||
|
||
export const disableCreateFactory = false; | ||
|
||
export const disableTextareaChildren = false; | ||
|
||
export const disableMapsAsChildren = false; | ||
|
||
export const disableUnstableRenderSubtreeIntoContainer = false; | ||
|
||
export const warnUnstableRenderSubtreeIntoContainer = false; | ||
|
||
export const disableUnstableCreatePortal = false; | ||
|
||
export const isTestEnvironment = true; | ||
|
||
// 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<FeatureFlagsShimType, FeatureFlagsType>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.