Skip to content

Commit 57cc504

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Migrate LogBox UI and parser Jest tests to Fantom (#57264)
Summary: Pull Request resolved: #57264 Migrates the LogBox UI component tests and the LogBox log parser test from regular Jest (`-test.js`) to Fantom (`-itest.js`). The 13 LogBox UI tests now render through the real React Native runtime; their snapshots were regenerated against the real Fabric output (replacing the previous mocked-component output) and reviewed for correctness. `it.each` was expanded into explicit cases (Fantom does not implement it). `parseLogBoxLog` was split: the general and Hermes cases run on Fantom, while the non-Hermes (JSC) `describe` block stays on Jest because it toggles `global.HermesInternal`, which is read-only under Fantom's Hermes runtime. The remaining LogBox tests stay on Jest because they depend on module mocks and/or fake timers that Fantom does not provide: `LogBoxData`, `LogBoxLog`, `LogBoxSymbolication`, `LogBox`, `LogBoxInspectorContainer`, and `LogBoxNotificationContainer`. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D108759078 fbshipit-source-id: 097e26de4174621b61bea8ddf860640fcbe70cf7
1 parent 4f71f26 commit 57cc504

53 files changed

Lines changed: 5370 additions & 5129 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native/Libraries/LogBox/Data/__tests__/parseLogBoxLog-itest.js

Lines changed: 776 additions & 0 deletions
Large diffs are not rendered by default.

packages/react-native/Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js

Lines changed: 1 addition & 751 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
12+
13+
import Text from '../../../Text/Text';
14+
import LogBoxButton from '../LogBoxButton';
15+
import * as Fantom from '@react-native/fantom';
16+
import * as React from 'react';
17+
18+
describe('LogBoxButton', () => {
19+
it('should render only a view without an onPress', () => {
20+
const root = Fantom.createRoot();
21+
Fantom.runTask(() => {
22+
root.render(
23+
<LogBoxButton
24+
backgroundColor={{
25+
default: 'black',
26+
pressed: 'red',
27+
}}>
28+
<Text>Press me</Text>
29+
</LogBoxButton>,
30+
);
31+
});
32+
33+
expect(root.getRenderedOutput().toJSX()).toMatchSnapshot();
34+
});
35+
36+
it('should render Pressable and pass through props', () => {
37+
const root = Fantom.createRoot();
38+
Fantom.runTask(() => {
39+
root.render(
40+
<LogBoxButton
41+
backgroundColor={{
42+
default: 'black',
43+
pressed: 'red',
44+
}}
45+
hitSlop={{}}
46+
onPress={() => {}}>
47+
<Text>Press me</Text>
48+
</LogBoxButton>,
49+
);
50+
});
51+
52+
expect(root.getRenderedOutput().toJSX()).toMatchSnapshot();
53+
});
54+
});

packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxButton-test.js

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
12+
13+
import LogBoxLog from '../../Data/LogBoxLog';
14+
import LogBoxInspector from '../LogBoxInspector';
15+
import * as Fantom from '@react-native/fantom';
16+
import * as React from 'react';
17+
18+
const logs = [
19+
new LogBoxLog({
20+
level: 'warn',
21+
isComponentError: false,
22+
message: {
23+
content: 'Some kind of message (first)',
24+
substitutions: [],
25+
},
26+
stack: [],
27+
category: 'Some kind of message (first)',
28+
componentStack: [],
29+
}),
30+
new LogBoxLog({
31+
level: 'error',
32+
isComponentError: false,
33+
message: {
34+
content: 'Some kind of message (second)',
35+
substitutions: [],
36+
},
37+
stack: [],
38+
category: 'Some kind of message (second)',
39+
componentStack: [],
40+
}),
41+
new LogBoxLog({
42+
level: 'fatal',
43+
isComponentError: false,
44+
message: {
45+
content: 'Some kind of message (third)',
46+
substitutions: [],
47+
},
48+
stack: [],
49+
category: 'Some kind of message (third)',
50+
componentStack: [],
51+
}),
52+
];
53+
54+
describe('LogBoxInspector', () => {
55+
it('should render null with no logs', () => {
56+
const root = Fantom.createRoot();
57+
Fantom.runTask(() => {
58+
root.render(
59+
<LogBoxInspector
60+
onDismiss={() => {}}
61+
onMinimize={() => {}}
62+
onChangeSelectedIndex={() => {}}
63+
logs={[]}
64+
selectedIndex={0}
65+
/>,
66+
);
67+
});
68+
69+
expect(root.getRenderedOutput().toJSX()).toMatchSnapshot();
70+
});
71+
72+
it('should render warning with selectedIndex 0', () => {
73+
const root = Fantom.createRoot();
74+
Fantom.runTask(() => {
75+
root.render(
76+
<LogBoxInspector
77+
onDismiss={() => {}}
78+
onMinimize={() => {}}
79+
onChangeSelectedIndex={() => {}}
80+
logs={logs}
81+
selectedIndex={0}
82+
/>,
83+
);
84+
});
85+
86+
expect(root.getRenderedOutput().toJSX()).toMatchSnapshot();
87+
});
88+
89+
it('should render fatal with selectedIndex 2', () => {
90+
const root = Fantom.createRoot();
91+
Fantom.runTask(() => {
92+
root.render(
93+
<LogBoxInspector
94+
onDismiss={() => {}}
95+
onMinimize={() => {}}
96+
onChangeSelectedIndex={() => {}}
97+
logs={logs}
98+
selectedIndex={2}
99+
fatalType="fatal"
100+
/>,
101+
);
102+
});
103+
104+
expect(root.getRenderedOutput().toJSX()).toMatchSnapshot();
105+
});
106+
});

packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspector-test.js

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)