From 9628fb8c8866cf13e7b8f4920846cadcd91b62b1 Mon Sep 17 00:00:00 2001 From: Arthur Bassi Date: Tue, 21 Jul 2026 10:49:16 -0300 Subject: [PATCH] fix(test): make FormData content-type assertion type-safe --- src/test/api/api-formdata-content-type.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/api/api-formdata-content-type.test.ts b/src/test/api/api-formdata-content-type.test.ts index 2db34987..b914b9f0 100644 --- a/src/test/api/api-formdata-content-type.test.ts +++ b/src/test/api/api-formdata-content-type.test.ts @@ -49,10 +49,12 @@ describe("api.post FormData Content-Type", () => { expect(capturedContentType).not.toBe("application/json"); // Browser sets multipart/form-data; boundary=... when Content-Type was stripped. - // In jsdom/fetch mock the runtime may leave it null or set multipart — both are OK + // In jsdom/fetch mock the runtime may leave it null or set multipart - both are OK // as long as it is not forced JSON. - if (capturedContentType) { - expect(capturedContentType.toLowerCase()).toContain("multipart/form-data"); + // Cast after expect(): Vitest assertion narrowing collapses string|null to never. + const contentType = capturedContentType as string | null; + if (contentType !== null) { + expect(contentType.toLowerCase()).toContain("multipart/form-data"); } }); });