Skip to content

Commit aa19d56

Browse files
author
Brian Vaughn
authored
Add test selectors to experimental build (#22760)
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.)
1 parent 520ffc7 commit aa19d56

File tree

9 files changed

+66
-47
lines changed

9 files changed

+66
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"scripts": {
110110
"build": "node ./scripts/rollup/build.js",
111111
"build-combined": "node ./scripts/rollup/build-all-release-channels.js",
112-
"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/",
112+
"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/",
113113
"build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV",
114114
"build-for-devtools-prod": "yarn build-for-devtools --type=NODE_PROD",
115115
"linc": "node ./scripts/tasks/linc.js",

packages/react-devtools-inline/webpack.config.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ const babelOptions = {
3333
),
3434
};
3535

36+
const builtModulesDir = resolve(
37+
__dirname,
38+
'..',
39+
'..',
40+
'build',
41+
'oss-experimental',
42+
);
43+
3644
module.exports = {
3745
mode: __DEV__ ? 'development' : 'production',
3846
devtool: __DEV__ ? 'eval-cheap-source-map' : 'source-map',
@@ -49,12 +57,10 @@ module.exports = {
4957
libraryTarget: 'commonjs2',
5058
},
5159
externals: {
52-
react: 'react',
53-
// TODO: Once this package is published, remove the external
54-
// 'react-debug-tools': 'react-debug-tools',
55-
'react-dom': 'react-dom',
56-
'react-is': 'react-is',
57-
scheduler: 'scheduler',
60+
react: resolve(builtModulesDir, 'react'),
61+
'react-dom': resolve(builtModulesDir, 'react-dom/unstable_testing'),
62+
'react-is': resolve(builtModulesDir, 'react-is'),
63+
scheduler: resolve(builtModulesDir, 'scheduler'),
5864
},
5965
node: {
6066
// source-maps package has a dependency on 'fs'

packages/react-devtools-shell/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const config = {
5555
react: resolve(builtModulesDir, 'react'),
5656
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
5757
'react-devtools-feature-flags': resolveFeatureFlags('shell'),
58-
'react-dom': resolve(builtModulesDir, 'react-dom'),
58+
'react-dom': resolve(builtModulesDir, 'react-dom/unstable_testing'),
5959
'react-is': resolve(builtModulesDir, 'react-is'),
6060
scheduler: resolve(builtModulesDir, 'scheduler'),
6161
},

packages/react-dom/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"server.browser.js",
3535
"server.node.js",
3636
"test-utils.js",
37+
"unstable_testing.js",
3738
"cjs/",
3839
"umd/"
3940
],

packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.internal.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('ReactDOMTestSelectors', () => {
5656
});
5757

5858
describe('findAllNodes', () => {
59-
// @gate www
59+
// @gate www || experimental
6060
it('should support searching from the document root', () => {
6161
function Example() {
6262
return (
@@ -76,7 +76,7 @@ describe('ReactDOMTestSelectors', () => {
7676
expect(matches[0].id).toBe('match');
7777
});
7878

79-
// @gate www
79+
// @gate www || experimental
8080
it('should support searching from the container', () => {
8181
function Example() {
8282
return (
@@ -96,7 +96,7 @@ describe('ReactDOMTestSelectors', () => {
9696
expect(matches[0].id).toBe('match');
9797
});
9898

99-
// @gate www
99+
// @gate www || experimental
100100
it('should support searching from a previous match if the match had a data-testname', () => {
101101
function Outer() {
102102
return (
@@ -127,7 +127,7 @@ describe('ReactDOMTestSelectors', () => {
127127
expect(matches[0].id).toBe('inner');
128128
});
129129

130-
// @gate www
130+
// @gate www || experimental
131131
it('should not support searching from a previous match if the match did not have a data-testname', () => {
132132
function Outer() {
133133
return (
@@ -157,7 +157,7 @@ describe('ReactDOMTestSelectors', () => {
157157
);
158158
});
159159

160-
// @gate www
160+
// @gate www || experimental
161161
it('should support an multiple component types in the selector array', () => {
162162
function Outer() {
163163
return (
@@ -211,7 +211,7 @@ describe('ReactDOMTestSelectors', () => {
211211
expect(matches[0].id).toBe('match3');
212212
});
213213

214-
// @gate www
214+
// @gate www || experimental
215215
it('should find multiple matches', () => {
216216
function Example1() {
217217
return (
@@ -249,7 +249,7 @@ describe('ReactDOMTestSelectors', () => {
249249
]);
250250
});
251251

252-
// @gate www
252+
// @gate www || experimental
253253
it('should ignore nested matches', () => {
254254
function Example() {
255255
return (
@@ -269,7 +269,7 @@ describe('ReactDOMTestSelectors', () => {
269269
expect(matches[0].id).toEqual('match1');
270270
});
271271

272-
// @gate www
272+
// @gate www || experimental
273273
it('should enforce the specific order of selectors', () => {
274274
function Outer() {
275275
return (
@@ -294,7 +294,7 @@ describe('ReactDOMTestSelectors', () => {
294294
).toHaveLength(0);
295295
});
296296

297-
// @gate www
297+
// @gate www || experimental
298298
it('should not search within hidden subtrees', () => {
299299
const ref1 = React.createRef(null);
300300
const ref2 = React.createRef(null);
@@ -324,7 +324,7 @@ describe('ReactDOMTestSelectors', () => {
324324
expect(matches[0]).toBe(ref2.current);
325325
});
326326

327-
// @gate www
327+
// @gate www || experimental
328328
it('should support filtering by display text', () => {
329329
function Example() {
330330
return (
@@ -347,7 +347,7 @@ describe('ReactDOMTestSelectors', () => {
347347
expect(matches[0].id).toBe('match');
348348
});
349349

350-
// @gate www
350+
// @gate www || experimental
351351
it('should support filtering by explicit accessibiliy role', () => {
352352
function Example() {
353353
return (
@@ -372,7 +372,7 @@ describe('ReactDOMTestSelectors', () => {
372372
expect(matches[0].id).toBe('match');
373373
});
374374

375-
// @gate www
375+
// @gate www || experimental
376376
it('should support filtering by explicit secondary accessibiliy role', () => {
377377
const ref = React.createRef();
378378

@@ -397,7 +397,7 @@ describe('ReactDOMTestSelectors', () => {
397397
expect(matches[0]).toBe(ref.current);
398398
});
399399

400-
// @gate www
400+
// @gate www || experimental
401401
it('should support filtering by implicit accessibiliy role', () => {
402402
function Example() {
403403
return (
@@ -420,7 +420,7 @@ describe('ReactDOMTestSelectors', () => {
420420
expect(matches[0].id).toBe('match');
421421
});
422422

423-
// @gate www
423+
// @gate www || experimental
424424
it('should support filtering by implicit accessibiliy role with attributes qualifications', () => {
425425
function Example() {
426426
return (
@@ -443,7 +443,7 @@ describe('ReactDOMTestSelectors', () => {
443443
expect(matches[0].id).toBe('match');
444444
});
445445

446-
// @gate www
446+
// @gate www || experimental
447447
it('should support searching ahead with the has() selector', () => {
448448
function Example() {
449449
return (
@@ -479,14 +479,14 @@ describe('ReactDOMTestSelectors', () => {
479479
expect(matches[0].id).toBe('match');
480480
});
481481

482-
// @gate www
482+
// @gate www || experimental
483483
it('should throw if no container can be found', () => {
484484
expect(() => findAllNodes(document.body, [])).toThrow(
485485
'Could not find React container within specified host subtree.',
486486
);
487487
});
488488

489-
// @gate www
489+
// @gate www || experimental
490490
it('should throw if an invalid host root is specified', () => {
491491
const ref = React.createRef();
492492
function Example() {
@@ -502,7 +502,7 @@ describe('ReactDOMTestSelectors', () => {
502502
});
503503

504504
describe('getFindAllNodesFailureDescription', () => {
505-
// @gate www
505+
// @gate www || experimental
506506
it('should describe findAllNodes failures caused by the component type selector', () => {
507507
function Outer() {
508508
return <Middle />;
@@ -532,7 +532,7 @@ No matching component was found for:
532532
);
533533
});
534534

535-
// @gate www
535+
// @gate www || experimental
536536
it('should return null if findAllNodes was able to find a match', () => {
537537
function Example() {
538538
return (
@@ -568,7 +568,7 @@ No matching component was found for:
568568
};
569569
}
570570

571-
// @gate www
571+
// @gate www || experimental
572572
it('should return a single rect for a component that returns a single root host element', () => {
573573
const ref = React.createRef();
574574

@@ -602,7 +602,7 @@ No matching component was found for:
602602
});
603603
});
604604

605-
// @gate www
605+
// @gate www || experimental
606606
it('should return a multiple rects for multiple matches', () => {
607607
const outerRef = React.createRef();
608608
const innerRef = React.createRef();
@@ -652,7 +652,7 @@ No matching component was found for:
652652
});
653653
});
654654

655-
// @gate www
655+
// @gate www || experimental
656656
it('should return a multiple rects for single match that returns a fragment', () => {
657657
const refA = React.createRef();
658658
const refB = React.createRef();
@@ -702,7 +702,7 @@ No matching component was found for:
702702
});
703703
});
704704

705-
// @gate www
705+
// @gate www || experimental
706706
it('should merge overlapping rects', () => {
707707
const refA = React.createRef();
708708
const refB = React.createRef();
@@ -757,7 +757,7 @@ No matching component was found for:
757757
});
758758
});
759759

760-
// @gate www
760+
// @gate www || experimental
761761
it('should merge some types of adjacent rects (if they are the same in one dimension)', () => {
762762
const refA = React.createRef();
763763
const refB = React.createRef();
@@ -857,7 +857,7 @@ No matching component was found for:
857857
});
858858
});
859859

860-
// @gate www
860+
// @gate www || experimental
861861
it('should not search within hidden subtrees', () => {
862862
const refA = React.createRef();
863863
const refB = React.createRef();
@@ -914,7 +914,7 @@ No matching component was found for:
914914
});
915915

916916
describe('focusWithin', () => {
917-
// @gate www
917+
// @gate www || experimental
918918
it('should return false if the specified component path has no matches', () => {
919919
function Example() {
920920
return <Child />;
@@ -935,7 +935,7 @@ No matching component was found for:
935935
expect(didFocus).toBe(false);
936936
});
937937

938-
// @gate www
938+
// @gate www || experimental
939939
it('should return false if there are no focusable elements within the matched subtree', () => {
940940
function Example() {
941941
return <Child />;
@@ -953,7 +953,7 @@ No matching component was found for:
953953
expect(didFocus).toBe(false);
954954
});
955955

956-
// @gate www
956+
// @gate www || experimental
957957
it('should return false if the only focusable elements are disabled', () => {
958958
function Example() {
959959
return (
@@ -971,7 +971,7 @@ No matching component was found for:
971971
expect(didFocus).toBe(false);
972972
});
973973

974-
// @gate www
974+
// @gate www || experimental
975975
it('should return false if the only focusable elements are hidden', () => {
976976
function Example() {
977977
return <button hidden={true}>not clickable</button>;
@@ -985,7 +985,7 @@ No matching component was found for:
985985
expect(didFocus).toBe(false);
986986
});
987987

988-
// @gate www
988+
// @gate www || experimental
989989
it('should successfully focus the first focusable element within the tree', () => {
990990
const secondRef = React.createRef(null);
991991

@@ -1040,7 +1040,7 @@ No matching component was found for:
10401040
expect(handleThirdFocus).not.toHaveBeenCalled();
10411041
});
10421042

1043-
// @gate www
1043+
// @gate www || experimental
10441044
it('should successfully focus the first focusable element even if application logic interferes', () => {
10451045
const ref = React.createRef(null);
10461046

@@ -1070,7 +1070,7 @@ No matching component was found for:
10701070
expect(handleFocus).toHaveBeenCalledTimes(1);
10711071
});
10721072

1073-
// @gate www
1073+
// @gate www || experimental
10741074
it('should not focus within hidden subtrees', () => {
10751075
const secondRef = React.createRef(null);
10761076

@@ -1194,7 +1194,7 @@ No matching component was found for:
11941194
window.IntersectionObserver = IntersectionObserver;
11951195
});
11961196

1197-
// @gate www
1197+
// @gate www || experimental
11981198
it('should notify a listener when the underlying instance intersection changes', () => {
11991199
const ref = React.createRef(null);
12001200

@@ -1231,7 +1231,7 @@ No matching component was found for:
12311231
expect(handleVisibilityChange).toHaveBeenCalledWith([{rect, ratio: 0.5}]);
12321232
});
12331233

1234-
// @gate www
1234+
// @gate www || experimental
12351235
it('should notify a listener of multiple targets when the underlying instance intersection changes', () => {
12361236
const ref1 = React.createRef(null);
12371237
const ref2 = React.createRef(null);
@@ -1308,7 +1308,7 @@ No matching component was found for:
13081308
]);
13091309
});
13101310

1311-
// @gate www
1311+
// @gate www || experimental
13121312
it('should stop listening when its disconnected', () => {
13131313
const ref = React.createRef(null);
13141314

@@ -1343,7 +1343,7 @@ No matching component was found for:
13431343
});
13441344

13451345
// This test reuires gating because it relies on the __DEV__ only commit hook to work.
1346-
// @gate www && __DEV__
1346+
// @gate www || experimental && __DEV__
13471347
it('should update which targets its listening to after a commit', () => {
13481348
const ref1 = React.createRef(null);
13491349
const ref2 = React.createRef(null);
@@ -1422,7 +1422,7 @@ No matching component was found for:
14221422
]);
14231423
});
14241424

1425-
// @gate www
1425+
// @gate www || experimental
14261426
it('should not observe components within hidden subtrees', () => {
14271427
const ref1 = React.createRef(null);
14281428
const ref2 = React.createRef(null);

0 commit comments

Comments
 (0)