remove get-free-port
This commit is contained in:
parent
a4d4b5a2a2
commit
3d89657695
|
|
@ -130,8 +130,9 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
|||
if (typeof mockingProxyOption.port === 'number' && testInfoImpl.config.workers > 1)
|
||||
throw new Error(`Cannot share mocking proxy between multiple workers. Either disable parallel mode or set mockingProxy.port to 'inject'`);
|
||||
|
||||
const port = typeof mockingProxyOption.port === 'number' ? mockingProxyOption.port : await getFreePort();
|
||||
const mockingProxy = await playwright.mockingProxy.newProxy(port);
|
||||
const mockingProxy = await playwright.mockingProxy.newProxy(
|
||||
mockingProxyOption.port === 'inject' ? undefined : mockingProxyOption.port
|
||||
);
|
||||
await use(mockingProxy);
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
|
|
|
|||
|
|
@ -398,15 +398,3 @@ export async function removeDirAndLogToConsole(dir: string) {
|
|||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getFreePort() {
|
||||
const promise = new ManualPromise<number>();
|
||||
const server = net.createServer();
|
||||
server.unref();
|
||||
server.on('error', promise.reject);
|
||||
server.listen(0, () => {
|
||||
const { port } = server.address() as AddressInfo;
|
||||
server.close(() => promise.resolve(port));
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue