GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add test selectors to experimental build by bvaughn · Pull Request #22760 · react/react

Conversation

@bvaughn

@bvaughn bvaughn commented Nov 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I'd like to investigate what it might look like to write DevTools e2e tests using these selectors.

This change adds a new react-dom/unstable_testing entry point but I believe its contents will exactly match react-dom/index for the stable build. (The experimental build will have the added new selector APIs.) See below on testing/verification of this assumption.

If we think it's important to not even include this file, I can look into that– not sure if our current build script supports this functionality at the moment though.


To test the result of this change on the built bundles, I ran:

yarn build-combined react-dom/testing  --type=NODE

Then compared build/oss-experimental/react-dom and build/oss-stable/react-dom.

The experimental build contains the following exports:

exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createComponentSelector = createComponentSelector;
exports.createHasPseudoClassSelector = createHasPseudoClassSelector;
exports.createPortal = createPortal$1;
exports.createRoleSelector = createRoleSelector;
exports.createRoot = createRoot;
exports.createTestNameSelector = createTestNameSelector;
exports.createTextSelector = createTextSelector;
exports.findAllNodes = findAllNodes;
exports.findBoundingRects = findBoundingRects;
exports.findDOMNode = findDOMNode;
exports.flushSync = flushSync$1;
exports.focusWithin = focusWithin;
exports.getFindAllNodesFailureDescription = getFindAllNodesFailureDescription;
exports.hydrate = hydrate;
exports.hydrateRoot = hydrateRoot;
exports.observeVisibleRects = observeVisibleRects;
exports.render = render;
exports.unmountComponentAtNode = unmountComponentAtNode;
exports.unstable_batchedUpdates = batchedUpdates$1;
exports.unstable_flushControlled = flushControlled;
exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
exports.unstable_runWithPriority = runWithPriority;
exports.version = ReactVersion;

And the stable build has the following:

exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = createPortal$1;
exports.createRoot = createRoot;
exports.findDOMNode = findDOMNode;
exports.flushSync = flushSync$1;
exports.hydrate = hydrate;
exports.hydrateRoot = hydrateRoot;
exports.render = render;
exports.unmountComponentAtNode = unmountComponentAtNode;
exports.unstable_batchedUpdates = batchedUpdates$1;
exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
exports.version = ReactVersion;

Note to self, after building this...

yarn build-for-devtools

I played around with this a bit in the test shell like so:

// react-devtools-shell/src/app/index.js

import * as Testing from 'react-dom';
window.Testing = Testing;

// In the console

const iframe = document.getElementById('target');
const testBody = iframe.contentWindow.document.body;
const Testing = iframe.contentWindow.Testing;

const firstToDoItem = Testing.findAllNodes(
  testBody,
  [Testing.createTextSelector('First')]
);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bvaughn
bvaughn requested review from acdlite, gaearon, jstejada, lunaruan, rickhanlonii and sebmarkbage November 15, 2021 13:52
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Nov 15, 2021
@sizebot

sizebot commented Nov 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 4ff5f57...a4d4e2f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 129.98 kB 129.98 kB = 41.56 kB 41.56 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 134.74 kB 134.74 kB = 42.96 kB 42.96 kB
facebook-www/ReactDOM-prod.classic.js = 424.31 kB 424.31 kB = 78.20 kB 78.20 kB
facebook-www/ReactDOM-prod.modern.js = 412.87 kB 412.87 kB = 76.47 kB 76.47 kB
facebook-www/ReactDOMForked-prod.classic.js = 424.31 kB 424.31 kB = 78.20 kB 78.20 kB
oss-experimental/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 974.23 kB +∞% 0.00 kB 221.75 kB
oss-experimental/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 135.24 kB +∞% 0.00 kB 43.54 kB
oss-experimental/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB
oss-stable-semver/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 928.96 kB +∞% 0.00 kB 211.63 kB
oss-stable-semver/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 124.45 kB +∞% 0.00 kB 39.83 kB
oss-stable-semver/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB
oss-stable/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 928.96 kB +∞% 0.00 kB 211.63 kB
oss-stable/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 124.45 kB +∞% 0.00 kB 39.83 kB
oss-stable/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 974.23 kB +∞% 0.00 kB 221.75 kB
oss-experimental/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 135.24 kB +∞% 0.00 kB 43.54 kB
oss-experimental/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB
oss-stable-semver/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 928.96 kB +∞% 0.00 kB 211.63 kB
oss-stable-semver/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 124.45 kB +∞% 0.00 kB 39.83 kB
oss-stable-semver/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB
oss-stable/react-dom/cjs/react-dom-testing.development.js +∞% 0.00 kB 928.96 kB +∞% 0.00 kB 211.63 kB
oss-stable/react-dom/cjs/react-dom-testing.production.min.js +∞% 0.00 kB 124.45 kB +∞% 0.00 kB 39.83 kB
oss-stable/react-dom/unstable_testing.js +∞% 0.00 kB 1.38 kB +∞% 0.00 kB 0.67 kB

Generated by 🚫 dangerJS against a4d4e2f

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bvaughn
bvaughn marked this pull request as draft November 15, 2021 14:16
This was referenced Nov 15, 2021
Add e2e tests for inline package #22646
Closed
[RFC] Codemod invariant -> throw new Error #22435
Merged
@bvaughn
bvaughn force-pushed the react-dom/testing branch 2 times, most recently from 32622ae to 50f6211 Compare November 15, 2021 21:29
bvaughn
bvaughn commented Nov 15, 2021
View reviewed changes
Comment thread package.json
"build": "node ./scripts/rollup/build.js",
"build-combined": "node ./scripts/rollup/build-all-release-channels.js",
"build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE && cp -r ./build/node_modules build/oss-experimental/",
"build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/test,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE && cp -r ./build/node_modules build/oss-experimental/",

@bvaughn bvaughn Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes yarn build-for-devtools build a tiny bit faster, since we don't need e.g. server rendering stuff.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bvaughn
bvaughn commented Nov 15, 2021
View reviewed changes
Comment thread packages/react-devtools-shell/webpack.config.js Outdated
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
'react-devtools-feature-flags': resolveFeatureFlags('shell'),
'react-dom': resolve(builtModulesDir, 'react-dom'),
'react-dom': resolve(builtModulesDir, 'react-dom/testing'),

@bvaughn bvaughn Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure we're building the test shell with the version of react-dom that has the extra test selector APIs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bvaughn
bvaughn commented Nov 15, 2021
View reviewed changes
Comment thread packages/react-dom/testing.experimental.js
findBoundingRects,
focusWithin,
observeVisibleRects,
} from 'react-reconciler/src/ReactFiberReconciler';

@bvaughn bvaughn Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds the new APIs to the experimental NPM release.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bvaughn
bvaughn commented Nov 15, 2021
View reviewed changes
Comment thread packages/shared/forks/ReactFeatureFlags.testing.js Outdated
export const enableSelectiveHydration = false;
export const enableLazyElements = false;
export const enableCache = false;
export const enableCache = true;

@bvaughn bvaughn Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should have turned this on earlier but didn't matter before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaearon gaearon Nov 16, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be set to __EXPERIMENTAL__?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bvaughn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
bvaughn
bvaughn commented Nov 15, 2021
View reviewed changes
Comment thread scripts/rollup/bundles.js
{
moduleType: RENDERER,
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, NODE_DEV, NODE_PROD],

@bvaughn bvaughn Nov 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds the react-dom/testing entry point to the NPM build. I wish we could only do this for the __EXPERIMENTAL__ release channel but I don't think that's possible with our current Rollup configuration?

As it stands, this would add a /testing.jsentrypoint to the react-dom stable release but its exports would exactly match react-dom/index.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gaearon gaearon Nov 16, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename to unstable_testing in this case? We shouldn't ship it in a way that seems usable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bvaughn bvaughn Nov 16, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion.

Little weird that source paths/tests will refer to react-dom/testing but built stuff will need to refer to react-dom/unstable_testing but it's still an improvement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bvaughn
bvaughn force-pushed the react-dom/testing branch from 50f6211 to 2b840f2 Compare November 16, 2021 19:37
@bvaughn
bvaughn marked this pull request as ready for review November 16, 2021 19:42
@bvaughn
bvaughn force-pushed the react-dom/testing branch from 2b840f2 to cd2f004 Compare November 16, 2021 19:46
Brian Vaughn
Add test selectors to experimental build
a4d4e2f
@bvaughn
bvaughn force-pushed the react-dom/testing branch from cd2f004 to a4d4e2f Compare November 16, 2021 19:52
bvaughn
bvaughn commented Nov 16, 2021
View reviewed changes
Comment thread packages/shared/forks/ReactFeatureFlags.testing.js
export const enableSelectiveHydration = false;
export const enableLazyElements = false;
export const enableCache = false;
export const enableCache = __EXPERIMENTAL__;

@bvaughn bvaughn Nov 16, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should have been flipped on before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gaearon
gaearon approved these changes Nov 16, 2021
View reviewed changes
@bvaughn
bvaughn merged commit aa19d56 into react:main Nov 16, 2021
@bvaughn
bvaughn deleted the react-dom/testing branch November 16, 2021 21:27
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 29, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions c0c71a8...c1220eb
a596e98
Summary:
This sync includes the following changes:
- **[c1220eb](react/react@c1220ebdd )**: treat empty string as null ([#22807](react/react#22807)) //<salazarm>//
- **[09d9b17](react/react@09d9b1775 )**: Update deprecated features in ESLint configuration files. ([#22767](react/react#22767)) //<Esteban>//
- **[bddbfb8](react/react@bddbfb86d )**: Revert "Fix Node package.json ./ exports deprecation warning ([#22783](react/react#22783))" ([#22792](react/react#22792)) //<Sebastian Silbermann>//
- **[b831aec](react/react@b831aec48 )**: chore(fast-refresh): double check wasMounted ([#22740](react/react#22740)) //<anc95>//
- **[8edeb78](react/react@8edeb787b )**: Fix Node package.json ./ exports deprecation warning ([#22783](react/react#22783)) //<Rin Arakaki>//
- **[fdc1d61](react/react@fdc1d617a )**: Flag for client render fallback behavior on hydration mismatch ([#22787](react/react#22787)) //<salazarm>//
- **[aa19d56](react/react@aa19d569b )**: Add test selectors to experimental build ([#22760](react/react#22760)) //<Brian Vaughn>//
- **[520ffc7](react/react@520ffc77a )**: Use globalThis if possible for native fetch in browser build ([#22777](react/react#22777)) //<Jiachi Liu>//
- **[afbc2d0](react/react@afbc2d08f )**: Remove unused react-internal/invariant-args ESLint rule. ([#22778](react/react#22778)) //<Esteban>//
- **[ca94e26](react/react@ca94e2680 )**: Remove 'packages/shared/invariant.js' ([#22779](react/react#22779)) //<Esteban>//
- **[8356471](react/react@83564712b )**: Move SuspenseList to experimental channel ([#22765](react/react#22765)) //<Andrew Clark>//
- **[d4144e6](react/react@d4144e6e5 )**: fix : grammatical typo for test description ([#22764](react/react#22764)) //<Brijesh Prasad>//
- **[0b32951](react/react@0b329511b )**: chore: fix comment typo ([#22657](react/react#22657)) //<Han Han>//
- **[e6f60d2](react/react@e6f60d2ad )**: fix typos ([#22715](react/react#22715)) //<180909>//

Changelog:
[General][Changed] - React Native sync for revisions c0c71a8...c1220eb

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32646433

fbshipit-source-id: c534ee7a17141634700c90fc2c7b34bfbe17887a
@bvaughn bvaughn mentioned this pull request Dec 15, 2021
[react-devtools-inline][4.22.0]: broken published package #22958
Closed
bvaughn pushed a commit to bvaughn/react that referenced this pull request Dec 15, 2021
Brian Vaughn
Revert changes to react-devtools-inline Webpack config from PR react#…
b92d747
…22760
bvaughn pushed a commit that referenced this pull request Dec 15, 2021
Brian Vaughn
Revert changes to react-devtools-inline Webpack config from PR #22760 (…
b10c378
…#22961)
nevilm-lt pushed a commit to nevilm-lt/react that referenced this pull request Mar 14, 2022
Brian Vaughn @nevilm-lt
Revert changes to react-devtools-inline Webpack config from PR react#…
738f999
…22760 (react#22961)
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
Brian Vaughn @zhengjitf
Add test selectors to experimental build (react#22760)
7d56bed
This change adds a new "react-dom/unstable_testing" entry point but I believe its contents will exactly match "react-dom/index" for the stable build. (The experimental build will have the added new selector APIs.)
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
Brian Vaughn @zhengjitf
Revert changes to react-devtools-inline Webpack config from PR react#…
d3d90f7
…22760 (react#22961)
nevilm-lt pushed a commit to nevilm-lt/react that referenced this pull request Apr 22, 2022
Brian Vaughn @nevilm-lt
Revert changes to react-devtools-inline Webpack config from PR react#…
2b567b9
…22760 (react#22961)
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
Brian Vaughn
Add test selectors to experimental build (react#22760)
b10c514
This change adds a new "react-dom/unstable_testing" entry point but I believe its contents will exactly match "react-dom/index" for the stable build. (The experimental build will have the added new selector APIs.)
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
Brian Vaughn
Revert changes to react-devtools-inline Webpack config from PR react#…
951c8fa
…22760 (react#22961)
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
Brian Vaughn
Add test selectors to experimental build (react#22760)
35f9058
This change adds a new "react-dom/unstable_testing" entry point but I believe its contents will exactly match "react-dom/index" for the stable build. (The experimental build will have the added new selector APIs.)
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
Brian Vaughn
Revert changes to react-devtools-inline Webpack config from PR react#…
352a170
…22760 (react#22961)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gaearon gaearon gaearon approved these changes
@sebmarkbage sebmarkbage Awaiting requested review from sebmarkbage
@jstejada jstejada Awaiting requested review from jstejada
@rickhanlonii rickhanlonii Awaiting requested review from rickhanlonii
@lunaruan lunaruan Awaiting requested review from lunaruan
@acdlite acdlite Awaiting requested review from acdlite

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@bvaughn @sizebot @gaearon @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.