/
index.test.ts
35 lines (30 loc) · 1.02 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
describe('Edge config validations', () => {
let next: NextInstance
afterAll(() => next.destroy())
it('fails to build when unstable_allowDynamic is not a string', async () => {
next = await createNext({
skipStart: true,
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'middleware.js': `
import { NextResponse } from 'next/server'
export default async function middleware(request) {
return NextResponse.next()
}
eval('toto')
export const config = { unstable_allowDynamic: true }
`,
},
})
await expect(next.start()).rejects.toThrow('next build failed')
expect(next.cliOutput).toMatch(
`/middleware exported 'config.unstable_allowDynamic' contains invalid pattern 'true': Expected pattern to be a non-empty string`
)
})
})