-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
23 lines (21 loc) · 1.03 KB
/
Copy pathvitest.config.ts
File metadata and controls
23 lines (21 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { defineConfig } from 'vitest/config'
// Hermetic telemetry config for every test in this run, mirroring
// playwright.config.ts's e2e setup: any CanvasServer/TelemetryClient built
// with no explicit configPath falls back to STACKCANVAS_CONFIG_DIR before
// ~/.stackcanvas. Without this, tests that don't inject a telemetry client
// read the *real* machine-local config file — which, now that
// TelemetryClient's default transport is real `fetch` (M1-6 / #10), could
// fire genuine network requests during `pnpm test` on a dev machine that has
// ever granted consent locally. Tests that care about consent state still
// pass their own configPath/env and are unaffected by this default.
const telemetryConfigDir = mkdtempSync(join(tmpdir(), 'sc-unit-config-'))
export default defineConfig({
test: {
include: ['packages/**/*.test.ts'],
environment: 'node',
env: { STACKCANVAS_CONFIG_DIR: telemetryConfigDir },
},
})