Skip to content

Conversation

@jcppkkk
Copy link
Contributor

@jcppkkk jcppkkk commented Oct 31, 2025

This PR fixes test failures caused by environment variables from the user's .env file interfering with test expectations.

Changes Made

  • Jest Global Hooks: Added globalSetup and globalTeardown to backup and restore the .env file during testing
  • Environment Variable Cleanup: Clear OCO_ environment variables during test execution to prevent interference
  • Test Environment Reset: Modified the test's resetEnv function to avoid restoring OCO_ environment variables

Problem Solved

Previously, when users had OCO_ environment variables set in their .env file (like OCO_MODEL=gpt-5-mini, OCO_TOKENS_MAX_OUTPUT=8192), these would override the expected default values in tests, causing failures.

Solution

The fix ensures that:

  1. The .env file is temporarily backed up during test runs
  2. OCO_ environment variables are cleared from process.env
  3. Tests run with clean, predictable defaults
  4. The .env file is restored after testing

This maintains backward compatibility while ensuring reliable test execution.

- Add Jest global setup/teardown hooks to backup and restore .env file
- Clear OCO_ environment variables during test execution
- Modify test resetEnv function to prevent OCO_ env vars from interfering
- Prevent .env file from interfering with test expectations

This fixes the issue where tests were failing due to environment variables
from the user's .env file overriding the expected default config values.
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.

1 participant