From d52ecd353d446765bce158a12a46a8e7cd01c1d2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 08:51:15 +0100 Subject: [PATCH] test: tighten document extractor runtime assertions --- src/media/document-extractors.runtime.test.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/media/document-extractors.runtime.test.ts b/src/media/document-extractors.runtime.test.ts index dda3afd3630..77189146fbd 100644 --- a/src/media/document-extractors.runtime.test.ts +++ b/src/media/document-extractors.runtime.test.ts @@ -42,7 +42,7 @@ describe("extractDocumentContent", () => { }, }, }), - ).resolves.toMatchObject({ text: "pdf text", extractor: "pdf" }); + ).resolves.toStrictEqual({ text: "pdf text", images: [], extractor: "pdf" }); expect(extract).toHaveBeenCalledWith({ buffer: Buffer.from("pdf"), @@ -65,17 +65,23 @@ describe("extractDocumentContent", () => { }, ]); - await expect( - extractDocumentContent({ + let extractionError: unknown; + try { + await extractDocumentContent({ buffer: Buffer.from("pdf"), mimeType: "application/pdf", maxPages: 1, maxPixels: 100, minTextChars: 10, - }), - ).rejects.toMatchObject({ - message: "Document extraction failed for application/pdf", - cause, - }); + }); + } catch (error) { + extractionError = error; + } + expect(extractionError).toBeInstanceOf(Error); + if (!(extractionError instanceof Error)) { + throw new Error("expected extraction error"); + } + expect(extractionError.message).toBe("Document extraction failed for application/pdf"); + expect(extractionError.cause).toBe(cause); }); });