(body: string)
| 142 | } |
| 143 | |
| 144 | const startTextServer = async (body: string) => { |
| 145 | const server = http.createServer((_, response) => { |
| 146 | response.writeHead(200, { 'content-type': 'text/plain' }) |
| 147 | response.end(body) |
| 148 | }) |
| 149 | |
| 150 | await new Promise<void>((resolve, reject) => { |
| 151 | server.once('error', reject) |
| 152 | server.listen(0, '127.0.0.1', resolve) |
| 153 | }) |
| 154 | |
| 155 | const address = server.address() |
| 156 | if (!address || typeof address === 'string') |
| 157 | throw new Error('Failed to start test server.') |
| 158 | |
| 159 | httpServers.push(server) |
| 160 | return { |
| 161 | port: address.port, |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | describe('dev proxy CLI', () => { |
| 166 | afterEach(async () => { |
no test coverage detected