withTestEnv
withTestEnv(
env?): () =>void
Defined in: fixtures.ts:295
Set up test environment variables and return cleanup function.
Parameters
Section titled “Parameters”TestEnvSetup = DEFAULT_TEST_ENV
Environment variables to set
Returns
Section titled “Returns”Cleanup function to restore original values
():
void
Returns
Section titled “Returns”void
Example
Section titled “Example”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'); });});