process
Documentation / @wtf/project-vitest / process
The environment of a process a test starts: childEnv, the test’s own, but the resolve
hook that the test script gave Node by --import in NODE_OPTIONS.
Every process a test starts inherits NODE_OPTIONS, and Node then imports the hook as it starts:
from the process’s own working folder, where @wtf/project-resolve may not be installed, and in
pnpm, which fails under it. A process that reads the workspace’s packages from their source, as a
runtime a test boots, keeps the hook: it is given the test’s own environment.
import { spawnSync } from 'node:child_process'
import { childEnv } from '@wtf/project-vitest/process'
spawnSync('pnpm', ['run', 'prepare'], { cwd: 'packages/schemas', env: childEnv() })A helper of a test, which Vitest runs in Node: the environment is the test process’s own by
default, the one place it reads it of the process; it imports nothing but
@wtf/project-resolve/env, which imports nothing.
