Open geoidesic opened 1 year ago
Thanks for the report, would you be willing to put together a minimal reproduction in stackblitz or codesandbox?
@geoidesic go the exact same error, it seems it uses node-fetch underneath, its better to mock the global fetch directly
This workaround works just fine
Ofcourse set/restore global fetch back to the original in the afterEach/beforeEach
it('user not logged in', async () => {
// mock your fetch
globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
const headers = new Headers({
'content-type': 'application/json',
});
console.log('incomming url: %o', input);
return new Response('{ "message": "Ok" }', { status: 200, statusText: 'ok', headers });
};
// @ts-ignore
const boot = await import('../boot/preboot');
const result = boot.default();
});
I don't get this error if I run the fetch via the app code but via vitest using this mocking library then it gives this error:
Here's the test: