Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ beforeEach(() => {
});

afterEach(() => {
vi.unstubAllEnvs();
fs.rmSync(tmpDir, { recursive: true, force: true });
});

Expand Down
1 change: 0 additions & 1 deletion packages/capture-kit/src/recording/swift-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ beforeEach(() => {
});

afterEach(() => {
vi.unstubAllEnvs();
fs.rmSync(tmpDir, { recursive: true, force: true });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ beforeEach(() => {
});

afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});

Expand Down
1 change: 0 additions & 1 deletion packages/platform-android/src/__tests__/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import type { DoctorCheck } from '@agent-device/contracts/observability';

afterEach(() => {
resetAndroidTestImeActivationCacheForTests();
vi.unstubAllEnvs();
});

function fakeAdb(currentIme: string, previousIme = 'null'): AndroidAdbExecutor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ beforeEach(() => {

afterEach(() => {
vi.unstubAllGlobals();
vi.unstubAllEnvs();
});

test('waitForRunner propagates request cancellation without fallback', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ beforeEach(() => {

afterEach(() => {
vi.unstubAllGlobals();
vi.unstubAllEnvs();
});

test('sendRunnerCommandOnce does not retry or simulator fallback after request failure', async () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/platform-web/src/agent-browser-tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ for (const scenario of [
'agent-browser@0.27.1',
]);
} finally {
vi.unstubAllEnvs();
fs.rmSync(stateDir, { recursive: true, force: true });
}
});
Expand All @@ -235,7 +234,6 @@ test('managed agent-browser setup reports an install that produced no entry', as
);
});
} finally {
vi.unstubAllEnvs();
fs.rmSync(stateDir, { recursive: true, force: true });
}
});
Expand All @@ -261,7 +259,6 @@ test('managed agent-browser setup gives the install lock back on every path out'
);
});
} finally {
vi.unstubAllEnvs();
assert.deepEqual(lockPathsUnder(stateDir), []);
fs.rmSync(stateDir, { recursive: true, force: true });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ test('direct requests connect to the approved address through the real lookup',
}
} finally {
await new Promise<void>((resolve) => server.close(() => resolve()));
vi.unstubAllEnvs();
}
});
1 change: 0 additions & 1 deletion src/__tests__/client-metro-auto-companion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ afterEach(() => {
vi.useRealTimers();
vi.clearAllMocks();
vi.restoreAllMocks();
vi.unstubAllEnvs();
});

test('prepareMetroRuntime starts the local companion only after bridge setup needs it', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/cloud-connect-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { AgentDeviceClient } from '../agent-device-client.ts';
import { mkdtempForTestSync } from './test-utils/tmp-dir.ts';

afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
vi.restoreAllMocks();
});
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/cloud-connect-profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ vi.mock('../provider-webdriver.ts', () => ({
afterEach(() => {
vi.clearAllMocks();
vi.unstubAllGlobals();
vi.unstubAllEnvs();
});

const mockedResolveCloudAccessForConnect = vi.mocked(resolveCloudAccessForConnect);
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/remote-connection-platform-axis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { readRemoteConnectionState } from '../remote/remote-connection-state.ts'
afterEach(() => {
vi.clearAllMocks();
vi.restoreAllMocks();
vi.unstubAllEnvs();
});

test('proxy install against an iOS-bound connection is not refused as a platform change', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/remote-connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import type { AgentDeviceClient } from '../agent-device-client.ts';
afterEach(() => {
vi.clearAllMocks();
vi.restoreAllMocks();
vi.unstubAllEnvs();
});

test('deferred Metro config ignores perf-style kind values', () => {
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/update-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ beforeEach(() => {

afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllEnvs();
vi.useRealTimers();
Object.defineProperty(process.stderr, 'isTTY', {
configurable: true,
Expand Down
1 change: 0 additions & 1 deletion src/cli/commands/__tests__/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ vi.mock('../../../provider-device-runtimes.ts', () => {

afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllEnvs();
});

test('plugins list and remove route through the CLI and emits JSON without daemon access or plugin evaluation', async () => {
Expand Down
2 changes: 0 additions & 2 deletions src/daemon-client/__tests__/daemon-client-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ afterEach(() => {
mockRunCmdDetached.mockReset();
mockRunCmdSync.mockClear();
mockSleep.mockClear();
vi.unstubAllEnvs();
});

function makeTempStateDir(prefix: string): string {
Expand Down Expand Up @@ -503,7 +502,6 @@ test('sendToDaemon does not reuse reachable daemon metadata with mismatched vers
await closeLoopbackServer(staleDaemon.server);
await closeLoopbackServer(freshDaemon.server);
fs.rmSync(stateDir, { recursive: true, force: true });
vi.unstubAllEnvs();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const mockRunCmdDetached = vi.mocked(runCmdDetachedMonitored);

afterEach(() => {
mockRunCmdDetached.mockReset();
vi.unstubAllEnvs();
});

test('sendToDaemon refuses to replace a reachable daemon newer than the client', async (t) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const mockSpawnDaemon = vi.mocked(runCmdDetachedMonitored);

afterEach(() => {
mockSpawnDaemon.mockReset();
vi.unstubAllEnvs();
});

test('a caller naming a policy refuses a running daemon without that policy', async (t) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ afterEach(() => {
mockRunCmdDetached.mockReset();
mockSleep.mockReset();
mockSleep.mockImplementation(async () => {});
vi.unstubAllEnvs();
});

/** The code signature this client stamps on, and expects of, a daemon it may reuse. */
Expand Down
40 changes: 18 additions & 22 deletions src/mcp/__tests__/command-tools-operator-inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,22 @@ test('MCP refuses any argument the advertised schema does not list', async () =>
test('MCP still resolves operator env values outside the model-writable surface', async () => {
vi.stubEnv('AGENT_DEVICE_DAEMON_AUTH_TOKEN', 'operator-env-token');
vi.stubEnv('AGENT_DEVICE_STATE_DIR', '/operator/state-dir');
try {
const createdConfigs: Array<Record<string, unknown>> = [];
const calls: Array<{ name: string; input: Record<string, unknown> }> = [];
const executor = createCommandToolExecutor({
createClient: (config) => {
createdConfigs.push(config as Record<string, unknown>);
return {} as AgentDeviceClient;
},
runCommand: async (_client, name, input) => {
calls.push({ name, input: input as Record<string, unknown> });
return {};
},
});

const result = await executor.execute('wait', {});

assert.equal(result.isError, false);
assert.equal(calls[0]?.input.daemonAuthToken, 'operator-env-token');
assert.equal(createdConfigs[0]?.stateDir, '/operator/state-dir');
} finally {
vi.unstubAllEnvs();
}
const createdConfigs: Array<Record<string, unknown>> = [];
const calls: Array<{ name: string; input: Record<string, unknown> }> = [];
const executor = createCommandToolExecutor({
createClient: (config) => {
createdConfigs.push(config as Record<string, unknown>);
return {} as AgentDeviceClient;
},
runCommand: async (_client, name, input) => {
calls.push({ name, input: input as Record<string, unknown> });
return {};
},
});

const result = await executor.execute('wait', {});

assert.equal(result.isError, false);
assert.equal(calls[0]?.input.daemonAuthToken, 'operator-env-token');
assert.equal(createdConfigs[0]?.stateDir, '/operator/state-dir');
});
1 change: 0 additions & 1 deletion src/mcp/__tests__/command-tools-parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { validateAgainstSchema } from './output-schema-validator.ts';
import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts';

afterEach(() => {
vi.unstubAllEnvs();
if (temporaryDirectory) {
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
temporaryDirectory = undefined;
Expand Down
6 changes: 5 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export const MUTATION_EXCLUDED_TESTS: readonly string[] = [
...FUZZ_WORKER_TESTS,
];

// Env stubs never outlive the test that made them. Applied to every project below and imported by
// vitest.mutation.config.ts, so no lane can leave it out.
export const TEST_ISOLATION = { unstubEnvs: true } as const;

// Imported by vitest.mutation.config.ts so the two lanes cannot drift: a guard
// added here must reach the Stryker sandbox too.
export const SETUP_FILES = [
Expand Down Expand Up @@ -245,7 +249,7 @@ export default defineConfig({
setupFiles: SETUP_FILES,
},
},
],
].map((project) => ({ ...project, test: { ...TEST_ISOLATION, ...project.test } })),
Comment thread
thymikee marked this conversation as resolved.
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov', 'json-summary'],
Expand Down
3 changes: 2 additions & 1 deletion vitest.mutation.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
import { readTestScope, threadHostileTestFiles } from './scripts/mutation/test-scope.ts';
import { workspaceSourceAliases } from './scripts/mutation/workspace-aliases.ts';
import { MUTATION_EXCLUDED_TESTS, SETUP_FILES } from './vitest.config.ts';
import { MUTATION_EXCLUDED_TESTS, SETUP_FILES, TEST_ISOLATION } from './vitest.config.ts';

const repoRoot = path.dirname(fileURLToPath(import.meta.url));

Expand All @@ -27,5 +27,6 @@ export default defineConfig({
'**/node_modules/**',
],
setupFiles: [...SETUP_FILES],
...TEST_ISOLATION,
},
});
Loading