Skip to content

Commit 6c24560

Browse files
authored
fix: make sure we don't swallow errors inside the mock (#7899)
* Update LayoutComponent.tsx * Update LayoutComponent.tsx * try to fix build * try removing babel override
1 parent a4074bc commit 6c24560

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/Mock/Components/LayoutComponent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export const LayoutComponent = class extends Component<ComponentProps> {
1919
return <View />;
2020
}
2121
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
22-
throw new Error(
23-
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`
22+
const err = new Error(
23+
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`,
2424
);
25+
(err as any).cause = error;
26+
throw err;
2527
}
2628
};
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const { NativeEventsReceiver } = jest.genMockFromModule('./NativeEventsReceiver');
1+
export const { NativeEventsReceiver } = jest.genMockFromModule(
2+
'./NativeEventsReceiver'
3+
) as typeof import('./NativeEventsReceiver');

lib/src/events/EventsRegistry.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ describe('EventsRegistry', () => {
1919
it('exposes appLaunched event', () => {
2020
const subscription = {};
2121
const cb = jest.fn();
22-
mockNativeEventsReceiver.registerAppLaunchedListener.mockReturnValueOnce(subscription);
22+
(mockNativeEventsReceiver.registerAppLaunchedListener as jest.MockedFunction<
23+
any
24+
>).mockReturnValueOnce(subscription);
2325

2426
const result = uut.registerAppLaunchedListener(cb);
2527

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
"release": "node ./scripts/release",
5151
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./"
5252
},
53-
"overrides": {
54-
"@babel/traverse": "7.22.6"
55-
},
5653
"peerDependencies": {
5754
"react": "*",
5855
"react-native": "*",
@@ -125,7 +122,7 @@
125122
"shell-utils": "1.x.x",
126123
"ts-mockito": "^2.3.1",
127124
"typedoc": "0.x.x",
128-
"typescript": "4.4.3"
125+
"typescript": "5.5.4"
129126
},
130127
"husky": {
131128
"hooks": {

0 commit comments

Comments
 (0)