Skip to content

Commit

Permalink
Improve expectSchemaShape to print names of mismatching keys
Browse files Browse the repository at this point in the history
  • Loading branch information
saevarb committed Sep 16, 2024
1 parent cccfe10 commit 4289c9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drizzle-zod/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export function expectSchemaShape<T extends z.ZodRawShape>(t: TaskContext, expec
expect(Object.keys(actual.shape)).toStrictEqual(Object.keys(expected.shape));

for (const key of Object.keys(actual.shape)) {
expect(actual.shape[key]!._def.typeName).toStrictEqual(expected.shape[key]?._def.typeName);
expect(actual.shape[key]!._def.typeName, `key: ${key}`).toStrictEqual(expected.shape[key]?._def.typeName);
if (actual.shape[key]?._def.typeName === 'ZodOptional') {
expect(actual.shape[key]!._def.innerType._def.typeName).toStrictEqual(
expect(actual.shape[key]!._def.innerType._def.typeName, `key: ${key}`).toStrictEqual(
actual.shape[key]!._def.innerType._def.typeName,
);
}
Expand Down

0 comments on commit 4289c9b

Please sign in to comment.