TypeError: (0 , _reactHooks.act) is not a function
matheus1lva opened this issue · 4 comments
matheus1lva commented
What is your question:
Ive being getting TypeError: (0 , _reactHooks.act) is not a function when requiringimport { act, renderHook } from '@testing-library/react-hooks';and runningact(() ...`
Most specificaly:
it('calls fetchReplacementOptionsRequest', async () => {
const mockFetchReplacementOptionsRequest = jest.fn().mockResolvedValue({});
jest
.spyOn(RuptureAnticipationActions, 'fetchReplacementOptionsRequest')
.mockImplementation(mockFetchReplacementOptionsRequest);
await act(async () => {
const { result } = await customRenderHook(useReplacementModalActions);
result.current.getReplacementOptions(orderId);
});
expect(mockFetchReplacementOptionsRequest).toHaveBeenCalledWith(orderId);
});
My setup is:
"@testing-library/react@12.1.2"
Found "@testing-library/dom@8.13.0"
=> Found "@testing-library/jest-dom@5.16.2"
=> Found "@testing-library/react-hooks@7.0.2"
=> Found "@testing-library/user-event@13.5.0"
What can i do?
joshuaellis commented
hey @matheus1lva,
What versions of react are you using?
matheus1lva commented
hey @matheus1lva,
What versions of react are you using?
Hi @joshuaellis !
react: 17.0.2
react-dom: 17.0.2
joshuaellis commented
Okay, are you using react-test-renderer and if so, what version?
matheus1lva commented
nvm, i`m glad you told me that. I looked for it and found misleading versions. It now works perfectly! Thanks :D