mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-22 01:07:18 +08:00
0f44fdf8af
* test: build dist/ before the suite when it is missing or stale (#1879) About thirty suites spawn dist/bin/codegraph.js, the parallel resolver loads its worker from dist/, and the `codegraph ui` suites serve dist/viewer/. On a fresh checkout `npm ci && npm test` failed them on spawn timeouts and a missing-viewer error that never mentioned the build; after an edit without a rebuild they quietly exercised the old code. A Vitest globalSetup now rebuilds each half only when it is missing or older than its sources: `tsc` + copy-assets when anything under src/ is newer than dist/bin/codegraph.js, `build:ui` when ui/src/ is newer than dist/viewer/index.html. A current dist/ costs one mtime walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(tests): build missing or stale test prerequisites (#1879) Dist-dependent tests launched missing or stale compiled outputs without a build prerequisite. Retain the contributor's shared setup and track build inputs and individual outputs for reliable invalidation. Resolve TypeScript locally, preserve asset copying and engine/UI separation, and report build failures directly. Add regression coverage for cold builds, warm runs, configuration changes, and missing assets. Co-authored-by: danusha2345 <ewidusoc498@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: danusha2345 <ewidusoc498@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
|
|
/**
|
|
* The SHARED base. `vitest.workspace.mts` extends it twice — once for the
|
|
* engine's node-environment suites and once for the viewer package's jsdom
|
|
* one — so the environment, the plugins and the module-resolution conditions
|
|
* a browser test needs cannot leak into the other 200-odd suites.
|
|
*/
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: 'node',
|
|
include: ['__tests__/**/*.test.ts'],
|
|
// Suites that spawn the built CLI need a current dist/ (#1879).
|
|
globalSetup: ['./__tests__/global-setup-dist.ts'],
|
|
/**
|
|
* Several MCP integration tests (mcp-daemon, mcp-initialize, mcp-ppid-watchdog,
|
|
* mcp-roots) spawn `dist/bin/codegraph.js serve --mcp` with `process.execPath`
|
|
* and rely on the child inheriting `process.env`. On a Node >= 25 dev machine
|
|
* the CLI's hard-block (src/bin/codegraph.ts) would otherwise exit the child
|
|
* before it ever responds, so every spawn-based test times out — see #478.
|
|
*
|
|
* Setting the override here keeps the CLI's runtime guard intact for end
|
|
* users (it's still enforced when `codegraph` is invoked directly) while
|
|
* letting the test suite run on whatever Node the contributor happens to
|
|
* have installed. CI on Node 22/23 is unaffected — the guard doesn't fire
|
|
* there, so the variable is a no-op.
|
|
*/
|
|
env: {
|
|
CODEGRAPH_ALLOW_UNSAFE_NODE: '1',
|
|
/**
|
|
* The suite spawns real CLI/MCP processes; without this they would write
|
|
* telemetry state into the contributor's real ~/.codegraph and count test
|
|
* tool calls as real usage. The telemetry unit tests are unaffected —
|
|
* they inject their own `env` via the Telemetry constructor.
|
|
*/
|
|
CODEGRAPH_TELEMETRY: '0',
|
|
},
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
},
|
|
},
|
|
});
|