Hi,
I am using unstable_dev (and vitest) to test my workers endpoints. It works well until I reach an endpoint that does a call to an external API. I’d like to mock that API to test multiple scenarios. I am trying to mock fetch to handle theses cases.
Mocking the global.fetch works inside the test himself but it does not change fetch implementation inside the worker under test.
Is there a way to fix that ?
beforeAll(async () => {
global.fetch = vi.fn()
worker = await unstable_dev('index.js', { disableExperimentalWarning: true });
});