Skip to content

Commit 1d96a89

Browse files
jamesadevineCopilot
andcommitted
fix(ado-script): exclude smoke test from default vitest run; consolidate shared tests
- Add vitest.config.ts with `include: ["src/**/*.test.ts"]` so the default `npm test` no longer picks up test/smoke.test.ts (which requires the ncc bundle to exist and was failing in CI before the build step ran). - Add vitest.config.smoke.ts targeting test/ for the smoke run. - Wire `npm run test:smoke` and the CI Smoke-test step to use the new smoke config (`vitest run -c vitest.config.smoke.ts`). - Move shared module tests under src/shared/__tests__/ to mirror the layout used by src/gate/__tests__/. Update relative imports (./foo.js → ../foo.js) and the vi.mock path in ado-client.test.ts. Validation: - `npm test` → 171/171 ✅ (smoke excluded) - `npx vitest run -c vitest.config.smoke.ts` after `npm run build` → 2/2 ✅ - `npm run typecheck` ✅ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2590059 commit 1d96a89

9 files changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/ado-script.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: Smoke-test bundle
6262
working-directory: scripts/ado-script
63-
run: npx vitest run test/smoke.test.ts
63+
run: npx vitest run -c vitest.config.smoke.ts
6464

6565
- name: E2E gate test
6666
run: cargo test --test gate_e2e -- --ignored --nocapture

scripts/ado-script/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build:check": "ls -lh ../gate.js && wc -c ../gate.js",
1313
"codegen": "mkdir -p schema && cargo run --quiet --manifest-path ../../Cargo.toml -- export-gate-schema --output schema/gate-spec.schema.json && npx json2ts schema/gate-spec.schema.json -o src/shared/types.gen.ts --bannerComment \"// AUTO-GENERATED from Rust IR via cargo run -- export-gate-schema. Do not edit; run npm run codegen.\"",
1414
"test": "vitest run",
15-
"test:smoke": "npm run build && vitest run test/smoke.test.ts",
15+
"test:smoke": "npm run build && vitest run -c vitest.config.smoke.ts",
1616
"lint": "echo TODO",
1717
"typecheck": "tsc --noEmit"
1818
},

scripts/ado-script/src/shared/ado-client.test.ts renamed to scripts/ado-script/src/shared/__tests__/ado-client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const { mockGitApi, mockBuildApi, mockWebApi, mockGetWebApi } = vi.hoisted(() =>
1919
return { mockGitApi, mockBuildApi, mockWebApi, mockGetWebApi };
2020
});
2121

22-
vi.mock("./auth.js", () => ({
22+
vi.mock("../auth.js", () => ({
2323
getWebApi: mockGetWebApi,
2424
_resetCacheForTesting: vi.fn(),
2525
}));
@@ -30,7 +30,7 @@ import {
3030
getIterationChanges,
3131
cancelBuild,
3232
withRetry,
33-
} from "./ado-client.js";
33+
} from "../ado-client.js";
3434

3535
describe("ado-client", () => {
3636
beforeEach(() => {

scripts/ado-script/src/shared/auth.test.ts renamed to scripts/ado-script/src/shared/__tests__/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2-
import { getWebApi, _resetCacheForTesting } from "./auth.js";
2+
import { getWebApi, _resetCacheForTesting } from "../auth.js";
33

44
describe("getWebApi", () => {
55
const originalEnv = { ...process.env };

scripts/ado-script/src/shared/env-facts.test.ts renamed to scripts/ado-script/src/shared/__tests__/env-facts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
stripRefPrefix,
55
isPipelineVarFact,
66
type FactKind,
7-
} from "./env-facts.js";
7+
} from "../env-facts.js";
88

99
const ALL: { fact: FactKind; env: string }[] = [
1010
{ fact: "pr_title", env: "ADO_PR_TITLE" },

scripts/ado-script/src/shared/policy.test.ts renamed to scripts/ado-script/src/shared/__tests__/policy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2-
import { PolicyTracker } from "./policy.js";
3-
import type { FactSpec } from "./types.gen.js";
2+
import { PolicyTracker } from "../policy.js";
3+
import type { FactSpec } from "../types.gen.js";
44

55
function spec(kind: string, fp: string): FactSpec {
66
return { kind, failure_policy: fp };

scripts/ado-script/src/shared/vso-logger.test.ts renamed to scripts/ado-script/src/shared/__tests__/vso-logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2-
import { setOutput, addBuildTag, logWarning, logError, complete } from "./vso-logger.js";
2+
import { setOutput, addBuildTag, logWarning, logError, complete } from "../vso-logger.js";
33

44
describe("vso-logger", () => {
55
let writes: string[];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
// Smoke-test config: targets the bundled gate.js end-to-end. The
6+
// suite must run AFTER `npm run build` produces dist/gate/index.js.
7+
include: ["test/**/*.test.ts"],
8+
},
9+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
// Default suite covers source-side tests under src/. The smoke test
6+
// under test/ depends on dist/gate/index.js existing, so it runs via
7+
// a separate config — see vitest.config.smoke.ts and
8+
// `npm run test:smoke`.
9+
include: ["src/**/*.test.ts"],
10+
},
11+
});
12+
13+

0 commit comments

Comments
 (0)