ccqa 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/run.ts +24 -2
- package/src/runtime/test-helpers.ts +7 -1
- package/src/runtime/vitest.config.ts +15 -0
package/package.json
CHANGED
package/src/cli/run.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
2
|
+
import { access, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
5
6
|
import {
|
|
6
7
|
parseSpecPath,
|
|
7
8
|
getTestScript,
|
|
@@ -10,6 +11,24 @@ import {
|
|
|
10
11
|
} from "../store/index.ts";
|
|
11
12
|
import * as log from "./logger.ts";
|
|
12
13
|
|
|
14
|
+
// Bundled vitest config used when the host project has no .ccqa/vitest.config.ts.
|
|
15
|
+
// Passing --config to vitest prevents it from discovering the host's
|
|
16
|
+
// vitest.config.ts and inheriting setupFiles/environment/aliases that were
|
|
17
|
+
// never meant to apply to ccqa's browser-driving specs.
|
|
18
|
+
const BUNDLED_VITEST_CONFIG = fileURLToPath(
|
|
19
|
+
new URL("../runtime/vitest.config.ts", import.meta.url),
|
|
20
|
+
);
|
|
21
|
+
const USER_VITEST_CONFIG = resolve(".ccqa/vitest.config.ts");
|
|
22
|
+
|
|
23
|
+
async function resolveVitestConfig(): Promise<string> {
|
|
24
|
+
try {
|
|
25
|
+
await access(USER_VITEST_CONFIG);
|
|
26
|
+
return USER_VITEST_CONFIG;
|
|
27
|
+
} catch {
|
|
28
|
+
return BUNDLED_VITEST_CONFIG;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
13
32
|
type VitestAssertionResult = {
|
|
14
33
|
status: "passed" | "failed" | "skipped" | "pending" | "todo";
|
|
15
34
|
title: string;
|
|
@@ -63,6 +82,7 @@ async function runTests(target?: string): Promise<void> {
|
|
|
63
82
|
const tmpDir = await mkdtemp(join(tmpdir(), "ccqa-run-"));
|
|
64
83
|
const summaries: SpecRunSummary[] = [];
|
|
65
84
|
let overallExitCode = 0;
|
|
85
|
+
const vitestConfig = await resolveVitestConfig();
|
|
66
86
|
|
|
67
87
|
try {
|
|
68
88
|
for (let i = 0; i < specs.length; i++) {
|
|
@@ -83,6 +103,8 @@ async function runTests(target?: string): Promise<void> {
|
|
|
83
103
|
"bunx",
|
|
84
104
|
"vitest",
|
|
85
105
|
"run",
|
|
106
|
+
"--config",
|
|
107
|
+
vitestConfig,
|
|
86
108
|
scriptFile,
|
|
87
109
|
"--reporter=json",
|
|
88
110
|
`--outputFile.json=${reportFile}`,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// Use createRequire instead of import.meta.resolve so this module works under
|
|
5
|
+
// Vite/Vitest's SSR transform (which replaces import.meta with a shim that
|
|
6
|
+
// lacks .resolve). import.meta.url survives the transform, so createRequire
|
|
7
|
+
// based on it can still locate peer-installed packages.
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const AB = require.resolve("agent-browser/bin/agent-browser.js");
|
|
4
10
|
|
|
5
11
|
type Result = { status: number | null; stdout: string; stderr: string };
|
|
6
12
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
// Default vitest config used by `ccqa run`. Passed via `--config` so the host
|
|
4
|
+
// project's vitest.config.ts is not picked up. ccqa specs are Node-side E2E
|
|
5
|
+
// tests driving agent-browser; host configs (setupFiles, jsdom/happy-dom
|
|
6
|
+
// environment, @ aliases, etc.) don't apply and often break the run.
|
|
7
|
+
//
|
|
8
|
+
// Consumers can override by placing .ccqa/vitest.config.ts in their project;
|
|
9
|
+
// `ccqa run` prefers that file when present.
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
test: {
|
|
12
|
+
environment: "node",
|
|
13
|
+
globals: false,
|
|
14
|
+
},
|
|
15
|
+
});
|