@ava/get-port
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@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.

Package Sidebar

Install

npm i @ava/get-port

Weekly Downloads

7,925

Version

2.0.0

License

MIT

Unpacked Size

7.64 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus
  • novemberborn