(getStderr, isDev)
| 25 | } |
| 26 | |
| 27 | const 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() |
no test coverage detected