diff --git a/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js b/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js index d331d283029..67d1cf29113 100644 --- a/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js +++ b/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js @@ -23,6 +23,7 @@ jest // findNodeHandle is imported from RendererProxy so mock that whole module. .setMock('../../ReactNative/RendererProxy', {findNodeHandle: () => 1}); +import {format} from 'node:util'; import * as React from 'react'; import TestRenderer from 'react-test-renderer'; @@ -295,11 +296,13 @@ describe('Native Animated', () => { useNativeDriver: true, }); + const consoleError = console.error; jest.spyOn(console, 'error').mockImplementationOnce((...args) => { - if (args[0].startsWith('The above error occurred in the')) { + const message = format(args); + if (message.includes('The above error occurred in the')) { return; } - console.errorDebug(...args); + consoleError(...args); }); expect(() => { diff --git a/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js b/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js index b40a7d885c5..8feafd86b64 100644 --- a/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js +++ b/packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js @@ -11,6 +11,7 @@ 'use strict'; import VirtualizedList from '../VirtualizedList'; +import {format} from 'node:util'; import React from 'react'; import ReactTestRenderer from 'react-test-renderer'; @@ -71,11 +72,12 @@ describe('VirtualizedList', () => { it('throws if no renderItem or ListItemComponent', () => { // Silence the React error boundary warning; we expect an uncaught error. const consoleError = console.error; - jest.spyOn(console, 'error').mockImplementation(message => { - if (message.startsWith('The above error occurred in the ')) { + jest.spyOn(console, 'error').mockImplementation((...args) => { + const message = format(...args); + if (message.includes('The above error occurred in the ')) { return; } - consoleError(message); + consoleError(...args); }); const componentFactory = () =>