test: convert functions to async & eliminate duplicates (#37316)
test: convert functions to async Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
969665eaa2
commit
f97d68c4bf
24 changed files with 225 additions and 343 deletions
|
@ -1,7 +1,10 @@
|
|||
import * as childProcess from 'child_process';
|
||||
import * as path from 'path';
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import * as net from 'net';
|
||||
import * as v8 from 'v8';
|
||||
import * as url from 'url';
|
||||
import { SuiteFunction, TestFunction } from 'mocha';
|
||||
import { BrowserWindow } from 'electron/main';
|
||||
import { AssertionError } from 'chai';
|
||||
|
@ -191,3 +194,11 @@ export async function itremote (name: string, fn: Function, args?: any[]) {
|
|||
if (!ok) { throw new AssertionError(message); }
|
||||
});
|
||||
}
|
||||
|
||||
export async function listen (server: http.Server | https.Server) {
|
||||
const hostname = '127.0.0.1';
|
||||
await new Promise<void>(resolve => server.listen(0, hostname, () => resolve()));
|
||||
const { port } = server.address() as net.AddressInfo;
|
||||
const protocol = (server instanceof https.Server) ? 'https' : 'http';
|
||||
return { port, url: url.format({ protocol, hostname, port }) };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue