( port: number, )
| 866 | } |
| 867 | |
| 868 | export const createServer = async ( |
| 869 | port: number, |
| 870 | ): Promise<ReturnType<typeof express>> => { |
| 871 | await waitForPort(port); // Wait until the port is available |
| 872 | |
| 873 | const e = express(); |
| 874 | // We need to specify the local IP address as the web server |
| 875 | // tends to fail with IPv6 related error: |
| 876 | // listen EADDRINUSE: address already in use :::50516 |
| 877 | await new Promise<void>((r) => e.listen(port, "0.0.0.0", r)); |
| 878 | return e; |
| 879 | }; |
| 880 | |
| 881 | async function waitForPort( |
| 882 | port: number, |
no test coverage detected