rsnext/test/e2e/app-dir/app-validation/validation.test.ts
Shu Ding 10f2268f4e
Add Zod and router state validation (#46962)
This PR adds Zod to the precompiled libraries, and use it to create schemas for the router state tree for validation. In other planned features/changes, Zod will also be used to do run-time data validation.

Fixes NEXT-135.
2023-03-10 13:37:45 +00:00

28 lines
655 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app dir validation',
{
files: __dirname,
skipDeployment: true,
},
({ next }) => {
it('should error when passing invalid router state tree', async () => {
const res = await next.fetch('/', {
headers: {
RSC: '1',
'Next-Router-State-Tree': JSON.stringify(['', '']),
},
})
expect(res.status).toBe(500)
const res2 = await next.fetch('/', {
headers: {
RSC: '1',
'Next-Router-State-Tree': JSON.stringify(['', {}]),
},
})
expect(res2.status).toBe(200)
})
}
)