MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/invalid-middleware-matchers/test/index.test.ts:27–147  ·  view source on GitHub ↗
(getStderr, isDev)

Source from the content-addressed store, hash-verified

25}
26
27const runTests = (getStderr, isDev) => {
28 it('should error when source length is exceeded', async () => {
29 await writeMiddleware([{ source: `/${Array(4096).join('a')}` }])
30 const stderr = await getStderr()
31 expect(stderr).toContain('exceeds max built length of 4096 for route')
32 })
33
34 it('should error during next build for invalid matchers', async () => {
35 await writeMiddleware([
36 {
37 // missing source
38 },
39 {
40 // invalid source
41 source: 123,
42 },
43 // missing forward slash in source
44 'hello',
45 {
46 // extra field
47 source: '/hello',
48 destination: '/not-allowed',
49 },
50
51 // invalid objects
52 null,
53 // invalid has items
54 {
55 source: '/hello',
56 has: [
57 {
58 type: 'cookiee',
59 key: 'loggedIn',
60 },
61 ],
62 },
63 {
64 source: '/hello',
65 has: [
66 {
67 type: 'headerr',
68 },
69 {
70 type: 'queryr',
71 key: 'hello',
72 },
73 ],
74 },
75 {
76 source: '/hello',
77 basePath: false,
78 },
79 {
80 source: '/hello',
81 locale: true,
82 },
83 ])
84 const stderr = await getStderr()

Callers 1

index.test.tsFile · 0.70

Calls 6

writeMiddlewareFunction · 0.85
getStderrFunction · 0.85
includesMethod · 0.80
itFunction · 0.50
expectFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected