export async function useCustomHook(data) {
useEffect(() => {
console.log('useEffect called');
async function callRemote() {
const isAuthenticated = await someApi();
data.isAuthenticated = isAuthenticated;
}
}, [data]);
callRemote();
}
import { renderHook } from "@testing-library/react-hooks/server";
import { useCustomHook } from '../useCustomHook';
test('it should set data obj', () => {
const dataMock = {};
renderHook(() =>
useCustomHook(dataMock);
);
expect(data.isAuthenticated).toBe(true);
})
The useEffect never gets called.
The line console.log('useEffect called'); isn't called.
Why isn't the useEffect hook every called in the test?