-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
@punkpeye
Description
Here is my test code:
// @vitest-environment jsdom import { useChatSessionFocus } from './useChatSessionFocus'; import { act, renderHook } from '@testing-library/react'; import { expect, it } from 'vitest'; it('focusMessages changes the focused component to messages', () => { const { result } = renderHook(() => useChatSessionFocus(true)); expect(result.current.focusedComponent).toBe('message-form'); act(() => { result.current.focusMessages(); }); expect(result.current.focusedComponent).toBe('messages'); });
It is failing in CI with:
×ばつ returns the expected initial state 10ms → React.act is not a function">
×ばつ returns the expected initial state 10ms
→ React.act is not a function
There is also a warning:
`ReactDOMTestUtils.act` is deprecated in favor of `React.act`. Import `act` from `react` instead of `react-dom/test-utils`. See https://react.dev/warnings/react-dom-test-utils for more info.
The confusing part is that the exact same test setup works perfectly fine locally.
I cannot figure out why vitest or react-testing-library is behaving differently in CI.
I already considered the possibility of version mismatch, but adding overrides didn't help:
"overrides": {
"zod": "3.24.2",
"react": "19.1.0",
"react-dom": "19.1.0"
},
Would appreciate any guidance.
Metadata
Metadata
Assignees
Labels
No labels