Skip to content

Commit 24c767b

Browse files
committed
test: handle React 19 render error logging
1 parent aa413eb commit 24c767b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/react/src/utils/testing.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {render as HTMLRender} from '@testing-library/react'
22
import {it, expect, vi} from 'vitest'
3+
import {reactMajorVersion} from './environment'
34

45
export function implementsClassName(Component: React.ElementType, baseClassName?: string) {
56
it('renders with the custom className', () => {
@@ -21,7 +22,9 @@ export function withExpectedConsoleError(callback: () => void) {
2122
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
2223
try {
2324
callback()
24-
expect(consoleSpy).toHaveBeenCalled()
25+
if (reactMajorVersion < 19) {
26+
expect(consoleSpy).toHaveBeenCalled()
27+
}
2528
} finally {
2629
consoleSpy.mockRestore()
2730
}

0 commit comments

Comments
 (0)