Skip to content

Commit 325a62b

Browse files
committed
test: update zod test
1 parent 18d0bb7 commit 325a62b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/validate.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ describe("Validate", () => {
9292
it("Invalid", async () => {
9393
const res = await request.post("/zod").send({ invalid: true });
9494
expect(res.status).toEqual(400);
95-
expect(res.body.data?.issues?.[0]?.code).toEqual("invalid_type");
95+
// TODO: zod5 error message is stringified
96+
const payload = JSON.parse(res.body.data.message);
97+
expect(payload[0].code).toEqual("invalid_type");
9698
});
9799
});
98100
});
@@ -110,7 +112,13 @@ describe("Validate", () => {
110112
app.use(
111113
"/zod",
112114
eventHandler(async (event) => {
113-
const data = await getValidatedQuery(event, zodValidate);
115+
const data = await getValidatedQuery(event, (data) => {
116+
try {
117+
return zodValidate(data);
118+
} catch (error) {
119+
console.log(error.toJSON());
120+
}
121+
});
114122
return data;
115123
}),
116124
);

0 commit comments

Comments
 (0)