cli
cli copied to clipboard
test: use ava/get-port plugin instead of randomizing ports based on process id
In the CLI tests we spawn multiple HTTP servers (directly and indirectly via CLI commands).
Since ava
run specs in different processes we randomize port acquisition based on process id:
https://github.com/netlify/cli/blob/db86f163451e0775a003ed60ab3c0dc452ef5992/tests/integration/utils/dev-server.js#L16
to avoid collisions.
With ava
version 4 we can use https://github.com/avajs/get-port to ensure ports are safely acquired across test files.
Note this is blocked by a Node.js 16.13.2 bug (see https://github.com/avajs/ava/issues/2947) as we had to disable worker threads which is required for ava/get-port
to worked.