diff --git a/server/__mocks__/fetch-with-proxy.ts b/server/__mocks__/fetch-with-proxy.ts new file mode 100644 index 0000000000..e52013f8d3 --- /dev/null +++ b/server/__mocks__/fetch-with-proxy.ts @@ -0,0 +1,9 @@ +import fetchMock from "jest-fetch-mock"; + +fetchMock.enableMocks(); + +// changes default behavior of fetchMock to use the real 'fetch' implementation. +// Mocks can now be enabled in each individual test with fetchMock.doMock() +fetchMock.dontMock(); + +export default fetch; diff --git a/server/queues/tasks/DeliverWebhookTask.test.ts b/server/queues/tasks/DeliverWebhookTask.test.ts index 348ee8c6ee..3e9610d3b8 100644 --- a/server/queues/tasks/DeliverWebhookTask.test.ts +++ b/server/queues/tasks/DeliverWebhookTask.test.ts @@ -14,12 +14,11 @@ beforeEach(() => flushdb()); beforeEach(() => { jest.resetAllMocks(); fetchMock.resetMocks(); + fetchMock.doMock(); }); const ip = "127.0.0.1"; -fetchMock.enableMocks(); - describe("DeliverWebhookTask", () => { test("should hit the subscription url and record a delivery", async () => { const subscription = await buildWebhookSubscription({