From c4ff8ae7222fa1971c15ce85f79b890db1c81873 Mon Sep 17 00:00:00 2001 From: Izaak Gough Date: Tue, 27 Oct 2026 16:47:06 +0000 Subject: [PATCH] test(storage-resize-images): trigger the config-load error with CONTENT_FILTER_LEVEL An invalid SHARP_OPTIONS is now rejected when the module loads, so it no longer reaches the handler's error logging. --- kits/storage-resize-images/tests/unhandled-error.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kits/storage-resize-images/tests/unhandled-error.test.ts b/kits/storage-resize-images/tests/unhandled-error.test.ts index c93c2285a..6a59c097b 100644 --- a/kits/storage-resize-images/tests/unhandled-error.test.ts +++ b/kits/storage-resize-images/tests/unhandled-error.test.ts @@ -50,7 +50,7 @@ async function invoke(event: unknown = cloudEvent): Promise { async function expectLoggedAtError( invocation: Promise, errorType: new (...args: never[]) => Error -): Promise { +): Promise { const err = await invocation.then( () => expect.fail("expected the trigger to throw"), (e: unknown) => e @@ -60,6 +60,7 @@ async function expectLoggedAtError( severity: "ERROR", message: (err as Error).stack, }); + return err as Error; } beforeEach(() => { @@ -76,9 +77,10 @@ afterEach(() => { }); test("an error loading config is logged at ERROR as its stack and rethrown", async () => { - vi.stubEnv("SHARP_OPTIONS", "{bad}"); + vi.stubEnv("CONTENT_FILTER_LEVEL", "bogus"); - await expectLoggedAtError(invoke(), SyntaxError); + const err = await expectLoggedAtError(invoke(), Error); + expect(err.message).toBe("Invalid HarmBlockThreshold: bogus"); }); test("an error after config loads is logged at ERROR as its stack and rethrown", async () => {