diff --git a/src/handlers/next/saleor-async-webhook.test.ts b/src/handlers/next/saleor-async-webhook.test.ts index 74bfa66..961d33b 100644 --- a/src/handlers/next/saleor-async-webhook.test.ts +++ b/src/handlers/next/saleor-async-webhook.test.ts @@ -160,14 +160,12 @@ describe("SaleorAsyncWebhook", () => { */ expect(res.statusCode).toBe(401); expect(res._getData()).toBe("My Body"); - /** - * TODO This assertion fails, due to WebhookError constructor: - * [TypeError: Class constructor WebhookError cannot be invoked without 'new'] - */ expect(onErrorCallback).toHaveBeenCalledWith( expect.objectContaining({ message: "Test error message", - }) + }), + req, + res ); /** diff --git a/src/handlers/next/saleor-async-webhook.ts b/src/handlers/next/saleor-async-webhook.ts index 4d81ffe..e49be13 100644 --- a/src/handlers/next/saleor-async-webhook.ts +++ b/src/handlers/next/saleor-async-webhook.ts @@ -20,7 +20,7 @@ interface WebhookManifestConfigurationBase { asyncEvent: AsyncWebhookEventType; isActive?: boolean; apl: APL; - onError?(error: WebhookError | Error): void; + onError?(error: WebhookError | Error, req: NextApiRequest, res: NextApiResponse): void; formatErrorResponse?( error: WebhookError | Error, req: NextApiRequest, @@ -163,7 +163,7 @@ export class SaleorAsyncWebhook { debug(`Validation error: ${e.message}`); if (this.onError) { - this.onError(e); + this.onError(e, req, res); } if (this.formatErrorResponse) { @@ -185,7 +185,7 @@ export class SaleorAsyncWebhook { debug("Unexpected error: %O", e); if (this.onError) { - this.onError(e); + this.onError(e, req, res); } if (this.formatErrorResponse) {