Skip to content
/ get-port Public

Cooperative get-port implementation

Notifications You must be signed in to change notification settings

avajs/get-port

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 10, 2022
bd4c2a4 · Jul 10, 2022

History

20 Commits
Jul 8, 2022
Jul 10, 2022
Nov 3, 2021
Jul 10, 2022
Sep 27, 2020
Sep 27, 2020
Sep 27, 2020
Sep 27, 2020
Nov 3, 2021
Nov 3, 2021
Jul 10, 2022
Nov 3, 2021

Repository files navigation

@ava/get-port

AVA 4 plugin which works like get-port, but ensures the port is locked across all test files.

Install this as a development dependency alongside AVA itself:

npm install --save-dev @ava/get-port

Usage

import getPort from '@ava/get-port';

test.before('get port', async t => {
  t.context.port = await getPort();
});

getPort() reserves a port, such that no other concurrently executing test file also using getPort() will select that same port. To ensure the port is available it then (briefly) listens. You can pass options used when listening. You can't pass port though.