react/packages/react-dom/unstable_testing.modern.fb.js

23 lines
544 B
JavaScript
Raw Normal View History

Export React as Named Exports instead of CommonJS (#18106) * Add options for forked entry points We currently fork .fb.js entry points. This adds a few more options. .modern.fb.js - experimental FB builds .classic.fb.js - stable FB builds .fb.js - if no other FB build, use this for FB builds .experimental.js - experimental builds .stable.js - stable builds .js - used if no other override exists This will be used to have different ES exports for different builds. * Switch React to named exports * Export named exports from the export point itself We need to re-export the Flow exported types so we can use them in our code. We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have. This should be able to use export * but I don't know why it doesn't work. This actually enables Flow typing of React which was just "any" before. This exposed some Flow errors that needs fixing. * Create forks for the react entrypoint None of our builds expose all exports and they all differ in at least one way, so we need four forks. * Set esModule flag to false We don't want to emit the esModule compatibility flag on our CommonJS output. For now we treat our named exports as if they're CommonJS. This is a potentially breaking change for scheduler (but all those apis are unstable), react-is and use-subscription. However, it seems unlikely that anyone would rely on this since these only have named exports. * Remove unused Feature Flags * Let jest observe the stable fork for stable tests This lets it do the negative test by ensuring that the right tests fail. However, this in turn will make other tests that are not behind __EXPERIMENTAL__ fail. So I need to do that next. * Put all tests that depend on exports behind __EXPERIMENTAL__ Since there's no way to override the exports using feature flags in .intern.js anymore we can't use these APIs in stable. The tradeoff here is that we can either enable the negative tests on "stable" that means experimental are expected to fail, or we can disable tests on stable. This is unfortunate since some of these APIs now run on a "stable" config at FB instead of the experimental. * Switch ReactDOM to named exports Same strategy as React. I moved the ReactDOMFB runtime injection to classic.fb.js Since we only fork the entrypoint, the `/testing` entrypoint needs to be forked too to re-export the same things plus `act`. This is a bit unfortunate. If it becomes a pattern we can consider forking in the module resolution deeply. fix flow * Fix ReactDOM Flow Types Now that ReactDOM is Flow type checked we need to fix up its types. * Configure jest to use stable entry for ReactDOM in non-experimental * Remove additional FeatureFlags that are no longer needed These are only flagging the exports and no implementation details so we can control them fully through the export overrides.
2020-02-26 05:54:27 +08:00
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
Export React as Named Exports instead of CommonJS (#18106) * Add options for forked entry points We currently fork .fb.js entry points. This adds a few more options. .modern.fb.js - experimental FB builds .classic.fb.js - stable FB builds .fb.js - if no other FB build, use this for FB builds .experimental.js - experimental builds .stable.js - stable builds .js - used if no other override exists This will be used to have different ES exports for different builds. * Switch React to named exports * Export named exports from the export point itself We need to re-export the Flow exported types so we can use them in our code. We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have. This should be able to use export * but I don't know why it doesn't work. This actually enables Flow typing of React which was just "any" before. This exposed some Flow errors that needs fixing. * Create forks for the react entrypoint None of our builds expose all exports and they all differ in at least one way, so we need four forks. * Set esModule flag to false We don't want to emit the esModule compatibility flag on our CommonJS output. For now we treat our named exports as if they're CommonJS. This is a potentially breaking change for scheduler (but all those apis are unstable), react-is and use-subscription. However, it seems unlikely that anyone would rely on this since these only have named exports. * Remove unused Feature Flags * Let jest observe the stable fork for stable tests This lets it do the negative test by ensuring that the right tests fail. However, this in turn will make other tests that are not behind __EXPERIMENTAL__ fail. So I need to do that next. * Put all tests that depend on exports behind __EXPERIMENTAL__ Since there's no way to override the exports using feature flags in .intern.js anymore we can't use these APIs in stable. The tradeoff here is that we can either enable the negative tests on "stable" that means experimental are expected to fail, or we can disable tests on stable. This is unfortunate since some of these APIs now run on a "stable" config at FB instead of the experimental. * Switch ReactDOM to named exports Same strategy as React. I moved the ReactDOMFB runtime injection to classic.fb.js Since we only fork the entrypoint, the `/testing` entrypoint needs to be forked too to re-export the same things plus `act`. This is a bit unfortunate. If it becomes a pattern we can consider forking in the module resolution deeply. fix flow * Fix ReactDOM Flow Types Now that ReactDOM is Flow type checked we need to fix up its types. * Configure jest to use stable entry for ReactDOM in non-experimental * Remove additional FeatureFlags that are no longer needed These are only flagging the exports and no implementation details so we can control them fully through the export overrides.
2020-02-26 05:54:27 +08:00
*
* 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.js';
Experimental test selector API (#18607) Adds several new experimental APIs to aid with automated testing. Each of the methods below accepts an array of "selectors" that identifies a path (or paths) through a React tree. There are four basic selector types: * Component: Matches Fibers with the specified React component type * Role: Matches Host Instances matching the (explicit or implicit) accessibility role. * Test name: Matches Host Instances with a data-testname attribute. * Text: Matches Host Instances that directly contain the specified text. * There is also a special lookahead selector type that enables further matching within a path (without actually including the path in the result). This selector type was inspired by the :has() CSS pseudo-class. It enables e.g. matching a <section> that contained a specific header text, then finding a like button within that <section>. API * findAllNodes(): Finds all Host Instances (e.g. HTMLElement) within a host subtree that match the specified selector criteria. * getFindAllNodesFailureDescription(): Returns an error string describing the matched and unmatched portions of the selector query. * findBoundingRects(): For all React components within a host subtree that match the specified selector criteria, return a set of bounding boxes that covers the bounds of the nearest (shallowed) Host Instances within those trees. * observeVisibleRects(): For all React components within a host subtree that match the specified selector criteria, observe if it’s bounding rect is visible in the viewport and is not occluded. * focusWithin(): For all React components within a host subtree that match the specified selector criteria, set focus within the first focusable Host Instance (as if you started before this component in the tree and moved focus forwards one step).
2020-05-06 01:37:46 +08:00
export {
createComponentSelector,
createHasPseudoClassSelector,
Experimental test selector API (#18607) Adds several new experimental APIs to aid with automated testing. Each of the methods below accepts an array of "selectors" that identifies a path (or paths) through a React tree. There are four basic selector types: * Component: Matches Fibers with the specified React component type * Role: Matches Host Instances matching the (explicit or implicit) accessibility role. * Test name: Matches Host Instances with a data-testname attribute. * Text: Matches Host Instances that directly contain the specified text. * There is also a special lookahead selector type that enables further matching within a path (without actually including the path in the result). This selector type was inspired by the :has() CSS pseudo-class. It enables e.g. matching a <section> that contained a specific header text, then finding a like button within that <section>. API * findAllNodes(): Finds all Host Instances (e.g. HTMLElement) within a host subtree that match the specified selector criteria. * getFindAllNodesFailureDescription(): Returns an error string describing the matched and unmatched portions of the selector query. * findBoundingRects(): For all React components within a host subtree that match the specified selector criteria, return a set of bounding boxes that covers the bounds of the nearest (shallowed) Host Instances within those trees. * observeVisibleRects(): For all React components within a host subtree that match the specified selector criteria, observe if it’s bounding rect is visible in the viewport and is not occluded. * focusWithin(): For all React components within a host subtree that match the specified selector criteria, set focus within the first focusable Host Instance (as if you started before this component in the tree and moved focus forwards one step).
2020-05-06 01:37:46 +08:00
createRoleSelector,
createTestNameSelector,
createTextSelector,
getFindAllNodesFailureDescription,
findAllNodes,
findBoundingRects,
focusWithin,
observeVisibleRects,
} from 'react-reconciler/src/ReactFiberReconciler';