From 9f2e96ce122b31a793be7c47d67c39ceb4754e74 Mon Sep 17 00:00:00 2001 From: Edoardo Scibona <12040076+velut@users.noreply.github.com> Date: Sat, 20 Apr 2024 23:09:27 +0200 Subject: [PATCH] test: preserve literal string values for parsing from db --- utils/json-strip.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/json-strip.ts b/utils/json-strip.ts index 07ea27d..4c9ce1a 100644 --- a/utils/json-strip.ts +++ b/utils/json-strip.ts @@ -1,8 +1,9 @@ import { z } from "zod"; const Literal = z.union([ - // Truncate strings and numbers to save space in the test DB. - z.string().transform(() => ""), + // Truncate strings and numbers to save space in the test DB + // but preserve the `type` property literal values. + z.string().transform((val) => (["module", "commonjs"].includes(val) ? val : "")), z.number().transform(() => 0), z.boolean(), z.null(),