Unique ports for each test server instance #3276
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This implements the test suite port assignment scheme described in #3247.
Currently, each end-to-end test suite in the project calls
testConfig
to get the configuration for the NestJS server it's supposed to create. The goal is fortestConfig
to return a unique port number for each test suite that calls it, so that no two test suites attempt to attach a test server to the same port. The current solution is for a ports.json file to keep track of the claimed ports so that a unique one can be chosen, but due to race conditions, this does not always work.To fix this, a new port assignment method is used. First,
glob
is used to get a list of all of the*.e2e-spec.ts
files in the project. Then,Error.prototype.stack
is used to get the filename of the test suite that is the caller oftestConfig
. The returned configuration will then contain a port number that is the sum of 3010 and the test suite's unique position in the ordered list of e2e test files.Breaking changes
Does this PR include any breaking changes we should be aware of?
Nope.
Checklist
📌 Always:
👍 Most of the time: