Skip to content

Commit b253b0f

Browse files
rubennortefacebook-github-bot
authored andcommitted
Create @react-native/fantom package (#48125)
Summary: Pull Request resolved: #48125 Changelog: [internal] This just moves the runtime modules for Fantom to its own package. Reviewed By: javache Differential Revision: D66825478 fbshipit-source-id: ac4dbc23b86895f09abc46345d497c1c53737ae2
1 parent 8d3c9ec commit b253b0f

File tree

15 files changed

+284
-273
lines changed

15 files changed

+284
-273
lines changed

jest/integration/config/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
rootDir: path.resolve(__dirname, '../../..'),
1717
roots: [
1818
'<rootDir>/packages/react-native',
19+
'<rootDir>/packages/react-native-fantom',
1920
'<rootDir>/jest/integration/runtime',
2021
],
2122
moduleFileExtensions: [...baseConfig.moduleFileExtensions, 'cpp', 'h'],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@react-native/fantom",
3+
"private": true,
4+
"version": "0.77.0-main",
5+
"main": "src/index.js",
6+
"description": "Internal integration testing and benchmarking tool for React Native",
7+
"peerDependencies":{
8+
"jest":"^29.7.0"
9+
}
10+
}

packages/react-native/src/private/__tests__/FantomFeatureFlags-itest.js renamed to packages/react-native-fantom/src/__tests__/FantomFeatureFlags-itest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @fantom_flags commonTestFlag:true jsOnlyTestFlag:true
1111
*/
1212

13-
import * as ReactNativeFeatureFlags from '../featureflags/ReactNativeFeatureFlags';
13+
import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';
1414

1515
describe('FantomFeatureFlags', () => {
1616
it('allows overridding common feature flags', () => {

packages/react-native/src/private/__tests__/ReactNativeTester-itest.js renamed to packages/react-native-fantom/src/__tests__/ReactNativeTester-itest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* @oncall react_native
1010
*/
1111

12-
import '../../../Libraries/Core/InitializeCore';
13-
import * as ReactNativeTester from './ReactNativeTester';
12+
import 'react-native/Libraries/Core/InitializeCore';
13+
import * as ReactNativeTester from '..';
1414

1515
describe('ReactNativeTester', () => {
1616
describe('runTask', () => {

packages/react-native/src/private/__tests__/ReactNativeTester.js renamed to packages/react-native-fantom/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import type {
1414
} from './FantomRenderedOutput';
1515
import type {MixedElement} from 'react';
1616

17-
import ReactFabric from '../../../Libraries/Renderer/shims/ReactFabric';
1817
import getFantomRenderedOutput from './FantomRenderedOutput';
18+
import ReactFabric from 'react-native/Libraries/Renderer/shims/ReactFabric';
1919

2020
let globalSurfaceIdCounter = 1;
2121

packages/react-native/Libraries/Components/TextInput/__tests__/TextInput-itest.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
*/
1212

1313
import '../../../Core/InitializeCore.js';
14-
import * as ReactNativeTester from '../../../../src/private/__tests__/ReactNativeTester';
1514
import TextInput from '../TextInput';
15+
import * as Fantom from '@react-native/fantom';
1616
import * as React from 'react';
1717
import {useEffect, useLayoutEffect, useRef} from 'react';
1818

1919
describe('TextInput', () => {
2020
it('creates view before dispatching view command from ref function', () => {
21-
const root = ReactNativeTester.createRoot();
21+
const root = Fantom.createRoot();
2222

23-
ReactNativeTester.runTask(() => {
23+
Fantom.runTask(() => {
2424
root.render(
2525
<TextInput
2626
ref={node => {
@@ -42,7 +42,7 @@ describe('TextInput', () => {
4242
});
4343

4444
it('creates view before dispatching view command from useLayoutEffect', () => {
45-
const root = ReactNativeTester.createRoot();
45+
const root = Fantom.createRoot();
4646

4747
function Component() {
4848
const textInputRef = useRef<null | React.ElementRef<typeof TextInput>>(
@@ -55,7 +55,7 @@ describe('TextInput', () => {
5555

5656
return <TextInput ref={textInputRef} />;
5757
}
58-
ReactNativeTester.runTask(() => {
58+
Fantom.runTask(() => {
5959
root.render(<Component />);
6060
});
6161

@@ -69,7 +69,7 @@ describe('TextInput', () => {
6969
});
7070

7171
it('creates view before dispatching view command from useEffect', () => {
72-
const root = ReactNativeTester.createRoot();
72+
const root = Fantom.createRoot();
7373

7474
function Component() {
7575
const textInputRef = useRef<null | React.ElementRef<typeof TextInput>>(
@@ -82,7 +82,7 @@ describe('TextInput', () => {
8282

8383
return <TextInput ref={textInputRef} />;
8484
}
85-
ReactNativeTester.runTask(() => {
85+
Fantom.runTask(() => {
8686
root.render(<Component />);
8787
});
8888

packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/setUpReactFabricPublicInstanceFantomTests.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import '../../../Core/InitializeCore.js';
1313

14-
import * as ReactNativeTester from '../../../../src/private/__tests__/ReactNativeTester';
1514
import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement';
1615
import TextInputState from '../../../Components/TextInput/TextInputState';
1716
import View from '../../../Components/View/View';
1817
import ReactFabricHostComponent from '../ReactFabricHostComponent';
18+
import * as Fantom from '@react-native/fantom';
1919
import nullthrows from 'nullthrows';
2020
import * as React from 'react';
2121

@@ -25,8 +25,8 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
2525
it('should provide instances of the right class as refs in host components', () => {
2626
let node;
2727

28-
const root = ReactNativeTester.createRoot();
29-
ReactNativeTester.runTask(() => {
28+
const root = Fantom.createRoot();
29+
Fantom.runTask(() => {
3030
root.render(
3131
<View
3232
ref={receivedNode => {
@@ -43,11 +43,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
4343

4444
describe('blur', () => {
4545
test('blur() invokes TextInputState', () => {
46-
const root = ReactNativeTester.createRoot();
46+
const root = Fantom.createRoot();
4747

4848
let maybeNode;
4949

50-
ReactNativeTester.runTask(() => {
50+
Fantom.runTask(() => {
5151
root.render(
5252
<View
5353
ref={node => {
@@ -64,7 +64,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
6464
// We don't support view commands in Fantom yet, so we have to mock this.
6565
TextInputState.blurTextInput = blurTextInput;
6666

67-
ReactNativeTester.runTask(() => {
67+
Fantom.runTask(() => {
6868
node.blur();
6969
});
7070

@@ -75,11 +75,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
7575

7676
describe('focus', () => {
7777
test('focus() invokes TextInputState', () => {
78-
const root = ReactNativeTester.createRoot();
78+
const root = Fantom.createRoot();
7979

8080
let maybeNode;
8181

82-
ReactNativeTester.runTask(() => {
82+
Fantom.runTask(() => {
8383
root.render(
8484
<View
8585
ref={node => {
@@ -96,7 +96,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
9696
// We don't support view commands in Fantom yet, so we have to mock this.
9797
TextInputState.focusTextInput = focusTextInput;
9898

99-
ReactNativeTester.runTask(() => {
99+
Fantom.runTask(() => {
100100
node.focus();
101101
});
102102

@@ -107,11 +107,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
107107

108108
describe('measure', () => {
109109
it('component.measure(...) invokes callback', () => {
110-
const root = ReactNativeTester.createRoot();
110+
const root = Fantom.createRoot();
111111

112112
let maybeNode;
113113

114-
ReactNativeTester.runTask(() => {
114+
Fantom.runTask(() => {
115115
root.render(
116116
<View
117117
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -132,11 +132,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
132132
});
133133

134134
it('unmounted.measure(...) does nothing', () => {
135-
const root = ReactNativeTester.createRoot();
135+
const root = Fantom.createRoot();
136136

137137
let maybeNode;
138138

139-
ReactNativeTester.runTask(() => {
139+
Fantom.runTask(() => {
140140
root.render(
141141
<View
142142
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -149,7 +149,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
149149

150150
const node = nullthrows(maybeNode);
151151

152-
ReactNativeTester.runTask(() => {
152+
Fantom.runTask(() => {
153153
root.render(<></>);
154154
});
155155

@@ -162,11 +162,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
162162

163163
describe('measureInWindow', () => {
164164
it('component.measureInWindow(...) invokes callback', () => {
165-
const root = ReactNativeTester.createRoot();
165+
const root = Fantom.createRoot();
166166

167167
let maybeNode;
168168

169-
ReactNativeTester.runTask(() => {
169+
Fantom.runTask(() => {
170170
root.render(
171171
<View
172172
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -187,11 +187,11 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
187187
});
188188

189189
it('unmounted.measureInWindow(...) does nothing', () => {
190-
const root = ReactNativeTester.createRoot();
190+
const root = Fantom.createRoot();
191191

192192
let maybeNode;
193193

194-
ReactNativeTester.runTask(() => {
194+
Fantom.runTask(() => {
195195
root.render(
196196
<View
197197
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -204,7 +204,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
204204

205205
const node = nullthrows(maybeNode);
206206

207-
ReactNativeTester.runTask(() => {
207+
Fantom.runTask(() => {
208208
root.render(<></>);
209209
});
210210

@@ -217,12 +217,12 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
217217

218218
describe('measureLayout', () => {
219219
it('component.measureLayout(component, ...) invokes callback', () => {
220-
const root = ReactNativeTester.createRoot();
220+
const root = Fantom.createRoot();
221221

222222
let maybeParentNode;
223223
let maybeChildNode;
224224

225-
ReactNativeTester.runTask(() => {
225+
Fantom.runTask(() => {
226226
root.render(
227227
<View
228228
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -250,12 +250,12 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
250250
});
251251

252252
it('unmounted.measureLayout(component, ...) does nothing', () => {
253-
const root = ReactNativeTester.createRoot();
253+
const root = Fantom.createRoot();
254254

255255
let maybeParentNode;
256256
let maybeChildNode;
257257

258-
ReactNativeTester.runTask(() => {
258+
Fantom.runTask(() => {
259259
root.render(
260260
<View
261261
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -275,7 +275,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
275275
const parentNode = nullthrows(maybeParentNode);
276276
const childNode = nullthrows(maybeChildNode);
277277

278-
ReactNativeTester.runTask(() => {
278+
Fantom.runTask(() => {
279279
root.render(
280280
<View style={{width: 100, height: 100, left: 10, top: 10}} />,
281281
);
@@ -288,12 +288,12 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
288288
});
289289

290290
it('component.measureLayout(unmounted, ...) does nothing', () => {
291-
const root = ReactNativeTester.createRoot();
291+
const root = Fantom.createRoot();
292292

293293
let maybeParentNode;
294294
let maybeChildNode;
295295

296-
ReactNativeTester.runTask(() => {
296+
Fantom.runTask(() => {
297297
root.render(
298298
<View
299299
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -313,7 +313,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
313313
const parentNode = nullthrows(maybeParentNode);
314314
const childNode = nullthrows(maybeChildNode);
315315

316-
ReactNativeTester.runTask(() => {
316+
Fantom.runTask(() => {
317317
root.render(
318318
<View style={{width: 100, height: 100, left: 10, top: 10}} />,
319319
);
@@ -326,12 +326,12 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
326326
});
327327

328328
it('unmounted.measureLayout(unmounted, ...) does nothing', () => {
329-
const root = ReactNativeTester.createRoot();
329+
const root = Fantom.createRoot();
330330

331331
let maybeParentNode;
332332
let maybeChildNode;
333333

334-
ReactNativeTester.runTask(() => {
334+
Fantom.runTask(() => {
335335
root.render(
336336
<View
337337
style={{width: 100, height: 100, left: 10, top: 10}}
@@ -351,7 +351,7 @@ export default function setUpTests({isModern}: {isModern: boolean}) {
351351
const parentNode = nullthrows(maybeParentNode);
352352
const childNode = nullthrows(maybeChildNode);
353353

354-
ReactNativeTester.runTask(() => {
354+
Fantom.runTask(() => {
355355
root.render(<></>);
356356
});
357357

0 commit comments

Comments
 (0)