Skip to content

chore: unset SYNTHETICS_API_KEY before tests to ensure clean test env #1050

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

Merged
merged 3 commits into from
Jul 16, 2025

Conversation

andrewvc
Copy link
Contributor

After more hours than I'd care to admit debugging bizarre test failures I discovered the issue was that I often have SYNTHETICS_API_KEY set locally. That causes many functional tests to fail, where they assume the user has no auth specified etc.

@andrewvc andrewvc self-assigned this Jul 15, 2025
@andrewvc andrewvc requested a review from Copilot July 15, 2025 23:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds logic to the Jest global setup to clear out any locally set SYNTHETICS_API_KEY so that tests run in a clean environment.

  • Unset SYNTHETICS_API_KEY if present in process.env before tests start.
  • Log a message when the variable is cleared.
Comments suppressed due to low confidence (1)

tests/utils/jest-global-setup.ts:31

  • Consider adding a test to verify that SYNTHETICS_API_KEY is indeed unset in the test environment. You could create a simple test case that checks process.env.SYNTHETICS_API_KEY is undefined after the global setup runs.
  if (process.env.SYNTHETICS_API_KEY) {

@andrewvc andrewvc changed the title Unset SYNTHETICS_API_KEY before tests to ensure clean test env fix: Unset SYNTHETICS_API_KEY before tests to ensure clean test env Jul 15, 2025
@andrewvc andrewvc changed the title fix: Unset SYNTHETICS_API_KEY before tests to ensure clean test env chore: Unset SYNTHETICS_API_KEY before tests to ensure clean test env Jul 15, 2025
andrewvc and others added 2 commits July 15, 2025 18:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@andrewvc andrewvc changed the title chore: Unset SYNTHETICS_API_KEY before tests to ensure clean test env chore: unset SYNTHETICS_API_KEY before tests to ensure clean test env Jul 16, 2025
Copy link
Contributor

@mcapell mcapell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andrewvc andrewvc merged commit 1e444dc into elastic:main Jul 16, 2025
8 of 9 checks passed
@andrewvc andrewvc deleted the unset_test_api_key branch July 16, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants