chore(tests): standardize env setup for tests #1255
Merged
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 of your changes
This maintenance PR fixes an issue highlighted in #1083 by standardizing the setup phase of all the Jest tests in the workspace. This PR makes the AWS Region in which integration tests are run configurable by the user while also setting a default in case no preference is specified.
Details
This PR makes sure the all packages in the monorepo are using the now standard
packages/*/tests/helpers/populateEnvironmentVariables.ts
file which is referenced in thejest.config.js
file and sets a number of standard environment variables throughout all tests.One of these variables is the
AWS_REGION
one. Before this PR, some packages (Tracer and Logger) were always setting it while others (Metrics) weren't. This caused some tests to always run in an AWS Region regardless of user explicit settings while others stayed configurable.The
populateEnvironmentVariables.ts
now checks if the user running the test has explicitly set the variable, if the variable is set it uses the value specified by the user, if it's not set is uses a default one (eu-west-1
).Other changes in this PR
Additionally, the PR also makes a small change to the


jest.config.js
files of each package to standardize the name & color shown in the console (housekeeping), i.e.:Once merged, this PR fixes #1083.
How to verify this change
See results of automated checks below the PR, or successful run of the integration tests here.
Additionally, you can optionally run any of the integration tests locally using the command below & verify that they are in fact run in the AWS Region you specify:
AWS_REGION=eu-central-1 npm run test:e2e:nodejs18x -w packages/metrics
Related issues, RFCs
Issue number: #1083
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.