Skip to content

withTestEnv

withTestEnv(env?): () => void

Defined in: fixtures.ts:295

Set up test environment variables and return cleanup function.

TestEnvSetup = DEFAULT_TEST_ENV

Environment variables to set

Cleanup function to restore original values

(): void

void

import { withTestEnv, DEFAULT_TEST_ENV } from 'vitest-agentic-control';
import { beforeEach, afterEach } from 'vitest';
describe('My Tests', () => {
let cleanup: () => void;
beforeEach(() => {
cleanup = withTestEnv(DEFAULT_TEST_ENV);
});
afterEach(() => {
cleanup();
});
it('should use test tokens', () => {
expect(process.env.GITHUB_TOKEN).toBe('ghp_test_token_12345');
});
});