Currently getting the TypeError: (0 , _reactdom.useFormStatus) is not a function
error with the below code
How do I properly mock react-dom
and useFormStatus
?
source code:
import { useFormStatus } from "react-dom";
export default function MyComponent(){
const {pending} = useFormStatus()
if(pending){
return <Loading />
}
return ( <div>some jsx</div>)
}
The test:
jest.mock("react-dom", () => ({
__esModule: true,
useFormStatus: jest.fn(() => ({ pending: false })),
}));
describe('MyTests', () => {
it('first test', () => {
render(<MyComponent />) // still has an error here
expect(1).toBe(1)
});
});