(isDev = false)
| 39 | let app |
| 40 | |
| 41 | const runTests = (isDev = false) => { |
| 42 | it.each([ |
| 43 | { |
| 44 | path: '/to-ANOTHER', |
| 45 | content: /could not be found/, |
| 46 | status: 404, |
| 47 | }, |
| 48 | { |
| 49 | path: '/HELLO-world', |
| 50 | content: /could not be found/, |
| 51 | status: 404, |
| 52 | }, |
| 53 | { |
| 54 | path: '/docs/GITHUB', |
| 55 | content: /could not be found/, |
| 56 | status: 404, |
| 57 | }, |
| 58 | { |
| 59 | path: '/add-HEADER', |
| 60 | content: /could not be found/, |
| 61 | status: 404, |
| 62 | }, |
| 63 | ])( |
| 64 | 'should honor caseSensitiveRoutes config for $path', |
| 65 | async ({ path, status, content }) => { |
| 66 | const res = await fetchViaHTTP(appPort, path, undefined, { |
| 67 | redirect: 'manual', |
| 68 | }) |
| 69 | |
| 70 | if (status) { |
| 71 | expect(res.status).toBe(status) |
| 72 | } |
| 73 | |
| 74 | if (content) { |
| 75 | expect(await res.text()).toMatch(content) |
| 76 | } |
| 77 | } |
| 78 | ) |
| 79 | |
| 80 | it('should successfully rewrite a WebSocket request', async () => { |
| 81 | const messages = [] |
| 82 | const ws = await new Promise<WebSocket>((resolve, reject) => { |
| 83 | let socket = new WebSocket(`ws://localhost:${appPort}/to-websocket`) |
| 84 | socket.on('message', (data) => { |
| 85 | messages.push(data.toString()) |
| 86 | }) |
| 87 | socket.on('open', () => resolve(socket)) |
| 88 | socket.on('error', (err) => { |
| 89 | console.error(err) |
| 90 | socket.close() |
| 91 | reject() |
| 92 | }) |
| 93 | }) |
| 94 | |
| 95 | await check( |
| 96 | () => (messages.length > 0 ? 'success' : JSON.stringify(messages)), |
| 97 | 'success' |
| 98 | ) |
no test coverage detected