Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions kits/storage-resize-images/tests/unhandled-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function invoke(event: unknown = cloudEvent): Promise<void> {
async function expectLoggedAtError(
invocation: Promise<void>,
errorType: new (...args: never[]) => Error
): Promise<void> {
): Promise<Error> {
Comment thread
IzaakGough marked this conversation as resolved.
const err = await invocation.then(
() => expect.fail("expected the trigger to throw"),
(e: unknown) => e
Expand All @@ -60,6 +60,7 @@ async function expectLoggedAtError(
severity: "ERROR",
message: (err as Error).stack,
});
return err as Error;
Comment thread
IzaakGough marked this conversation as resolved.
}

beforeEach(() => {
Expand All @@ -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 () => {
Expand Down
Loading