You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('POST /testing',()=>{it('should return the request body',async()=>{constres=awaitapp.request('/testing',{method: 'POST',body: JSON.stringify({key: 'value'}),})expect(awaitres.json()).toStrictEqual({key: 'value'})})})
However, I kept getting errors about the key field being missing.
After hours of debugging I noticed one example had the content-type header set in the app.request()
headers: new Headers({ 'Content-Type': 'application/json' }),
That turns out to be what the problem was. While I understand why it happened, it wasn't obvious that was the issue. It would be really useful if zValidator could return an error if the validation target is json but the content-type header is missing or does not contain application/json.
The text was updated successfully, but these errors were encountered:
I created a very simple zod-validator to use in my test suite.
My route looked like
My test looked like this
However, I kept getting errors about the
key
field being missing.After hours of debugging I noticed one example had the content-type header set in the
app.request()
That turns out to be what the problem was. While I understand why it happened, it wasn't obvious that was the issue. It would be really useful if zValidator could return an error if the validation target is
json
but the content-type header is missing or does not containapplication/json
.The text was updated successfully, but these errors were encountered: