Skip to content

chore(tests): standardize env setup for tests #1255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dreamorosi
Copy link
Contributor

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 the jest.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).

if (process.env.AWS_REGION === undefined && process.env.CDK_DEFAULT_REGION === undefined) {
  process.env.AWS_REGION = '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.:
Screenshot 2023-01-18 at 11 37 09
image

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

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dreamorosi dreamorosi self-assigned this Jan 18, 2023
@dreamorosi dreamorosi linked an issue Jan 18, 2023 that may be closed by this pull request
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Jan 18, 2023
@github-actions github-actions bot added the internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) label Jan 18, 2023
@dreamorosi dreamorosi merged commit 0991021 into main Jan 18, 2023
@dreamorosi dreamorosi deleted the 1083-maintenance-end-to-end-testing-work-only-on-eu-west-1-region branch January 18, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) size/M PR between 30-99 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: End-to-End testing work only on eu-west-1 region
1 participant