File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,9 @@ describe("Validate", () => {
92
92
it ( "Invalid" , async ( ) => {
93
93
const res = await request . post ( "/zod" ) . send ( { invalid : true } ) ;
94
94
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" ) ;
96
98
} ) ;
97
99
} ) ;
98
100
} ) ;
@@ -110,7 +112,13 @@ describe("Validate", () => {
110
112
app . use (
111
113
"/zod" ,
112
114
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
+ } ) ;
114
122
return data ;
115
123
} ) ,
116
124
) ;
You can’t perform that action at this time.
0 commit comments