| 20 | const containRegex = /(This page could not be found|Bad Request)/ |
| 21 | // test base mount point `public/` |
| 22 | const checkRes = async (res) => { |
| 23 | if (res.status === 308) { |
| 24 | const redirectDest = res.headers.get('location') |
| 25 | const parsedUrl = new URL(redirectDest) |
| 26 | expect(parsedUrl.hostname).toBeOneOf(['localhost', '127.0.0.1']) |
| 27 | } else { |
| 28 | try { |
| 29 | expect(res.status === 400 || res.status === 404).toBe(true) |
| 30 | } catch (err) { |
| 31 | require('console').error({ path, status: res.status }) |
| 32 | throw err |
| 33 | } |
| 34 | expect(await res.text()).toMatch(containRegex) |
| 35 | } |
| 36 | } |
| 37 | const res = await fetchViaHTTP(appPort, path, undefined, { |
| 38 | redirect: 'manual', |
| 39 | }) |