vitest-spock 0.6.0 → 0.10.0

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.
@@ -1,8 +1,19 @@
1
+ import { autoVerifyConsole } from "../auto.js";
1
2
  import { registerSpockMatchers, registerSpockTransport } from "../matcher.js";
2
3
  import { createNodeTransport } from "./runner.js";
4
+ function parseCsvEnv(value) {
5
+ if (value === undefined || value.trim().length === 0)
6
+ return undefined;
7
+ return value
8
+ .split(",")
9
+ .map((s) => s.trim())
10
+ .filter((s) => s.length > 0);
11
+ }
3
12
  /**
4
13
  * Configure `vitest-spock` for a Node Vitest environment: registers the local `spock` CLI
5
- * transport and Vitest's `toConformTo` matcher.
14
+ * transport and Vitest's `toConformTo` matcher. If `captureConsole` (or
15
+ * `VITEST_SPOCK_CAPTURE_CONSOLE=1` + `VITEST_SPOCK_SPEC`) is set, also hooks `console`
16
+ * automatically via [`autoVerifyConsole`].
6
17
  */
7
18
  export function setupNodeSpock(options) {
8
19
  const rootDir = options?.rootDir ?? process.env["VITEST_SPOCK_ROOT"] ?? process.cwd();
@@ -14,10 +25,31 @@ export function setupNodeSpock(options) {
14
25
  timeoutMs: options?.timeoutMs,
15
26
  }));
16
27
  registerSpockMatchers();
28
+ const autoCapture = options?.captureConsole ?? process.env["VITEST_SPOCK_CAPTURE_CONSOLE"] === "1";
29
+ const spec = options?.spec ?? process.env["VITEST_SPOCK_SPEC"];
30
+ if (autoCapture && spec !== undefined && spec.length > 0) {
31
+ const rawMaxStutters = process.env["VITEST_SPOCK_MAX_STUTTERS"];
32
+ const maxStutters = options?.maxStutters ??
33
+ (rawMaxStutters !== undefined && rawMaxStutters.length > 0
34
+ ? Number.parseInt(rawMaxStutters, 10)
35
+ : undefined);
36
+ autoVerifyConsole({
37
+ spec,
38
+ model: options?.model ?? process.env["VITEST_SPOCK_MODEL"],
39
+ requireAllActions: options?.requireAllActions ?? process.env["VITEST_SPOCK_REQUIRE_ALL_ACTIONS"] === "1",
40
+ requireActions: options?.requireActions ?? parseCsvEnv(process.env["VITEST_SPOCK_REQUIRE_ACTIONS"]),
41
+ requireAllFields: options?.requireAllFields ?? process.env["VITEST_SPOCK_REQUIRE_ALL_FIELDS"] === "1",
42
+ requireFields: options?.requireFields ?? parseCsvEnv(process.env["VITEST_SPOCK_REQUIRE_FIELDS"]),
43
+ maxStutters: Number.isNaN(maxStutters) ? undefined : maxStutters,
44
+ timeoutMs: options?.timeoutMs,
45
+ onMissingBinary: options?.onMissingBinary,
46
+ });
47
+ }
17
48
  }
18
49
  /**
19
50
  * Minimal Vite/Vitest plugin for Node projects. Exports `VITEST_SPOCK_ROOT` (and `SPOCK_BIN`
20
- * when specified) and registers `vitest-spock/node/setup` in `test.setupFiles`.
51
+ * / auto-capture settings when specified) and registers `vitest-spock/node/setup` in
52
+ * `test.setupFiles`.
21
53
  */
22
54
  export function spock(options) {
23
55
  return {
@@ -28,6 +60,25 @@ export function spock(options) {
28
60
  env["VITEST_SPOCK_ROOT"] = options.rootDir;
29
61
  if (options?.spockBin)
30
62
  env["SPOCK_BIN"] = options.spockBin;
63
+ if (options?.captureConsole)
64
+ env["VITEST_SPOCK_CAPTURE_CONSOLE"] = "1";
65
+ if (options?.spec)
66
+ env["VITEST_SPOCK_SPEC"] = options.spec;
67
+ if (options?.model)
68
+ env["VITEST_SPOCK_MODEL"] = options.model;
69
+ if (options?.requireAllActions)
70
+ env["VITEST_SPOCK_REQUIRE_ALL_ACTIONS"] = "1";
71
+ if (options?.requireActions && options.requireActions.length > 0) {
72
+ env["VITEST_SPOCK_REQUIRE_ACTIONS"] = options.requireActions.join(",");
73
+ }
74
+ if (options?.requireAllFields)
75
+ env["VITEST_SPOCK_REQUIRE_ALL_FIELDS"] = "1";
76
+ if (options?.requireFields && options.requireFields.length > 0) {
77
+ env["VITEST_SPOCK_REQUIRE_FIELDS"] = options.requireFields.join(",");
78
+ }
79
+ if (options?.maxStutters !== undefined) {
80
+ env["VITEST_SPOCK_MAX_STUTTERS"] = String(options.maxStutters);
81
+ }
31
82
  return {
32
83
  test: {
33
84
  env,
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/node/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAA0B,MAAM,aAAa,CAAC;AAE1E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAuC;IACpE,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC/D,sBAAsB,CACpB,mBAAmB,CAAC;QAClB,OAAO;QACP,QAAQ;QACR,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,SAAS,EAAE,OAAO,EAAE,SAAS;KAC9B,CAAC,CACH,CAAC;IACF,qBAAqB,EAAE,CAAC;AAC1B,CAAC;AAID;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,OAAwC;IAI5D,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,MAAM;YACJ,MAAM,GAAG,GAA2B,EAAE,CAAC;YACvC,IAAI,OAAO,EAAE,OAAO;gBAAE,GAAG,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;YACjE,IAAI,OAAO,EAAE,QAAQ;gBAAE,GAAG,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;YAC3D,OAAO;gBACL,IAAI,EAAE;oBACJ,GAAG;oBACH,UAAU,EAAE,CAAC,yBAAyB,CAAC;iBACxC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { registerSpockMatchers, registerSpockTransport } from \"../matcher.js\";\nimport { createNodeTransport, type NodeRunnerOptions } from \"./runner.js\";\n\n/**\n * Configure `vitest-spock` for a Node Vitest environment: registers the local `spock` CLI\n * transport and Vitest's `toConformTo` matcher.\n */\nexport function setupNodeSpock(options?: NodeRunnerOptions | undefined): void {\n const rootDir = options?.rootDir ?? process.env[\"VITEST_SPOCK_ROOT\"] ?? process.cwd();\n const spockBin = options?.spockBin ?? process.env[\"SPOCK_BIN\"];\n registerSpockTransport(\n createNodeTransport({\n rootDir,\n spockBin,\n onMissingBinary: options?.onMissingBinary,\n timeoutMs: options?.timeoutMs,\n }),\n );\n registerSpockMatchers();\n}\n\nexport type SpockPluginOptions = NodeRunnerOptions;\n\n/**\n * Minimal Vite/Vitest plugin for Node projects. Exports `VITEST_SPOCK_ROOT` (and `SPOCK_BIN`\n * when specified) and registers `vitest-spock/node/setup` in `test.setupFiles`.\n */\nexport function spock(options?: SpockPluginOptions | undefined): {\n name: string;\n config(): Record<string, unknown>;\n} {\n return {\n name: \"vitest-spock\",\n config() {\n const env: Record<string, string> = {};\n if (options?.rootDir) env[\"VITEST_SPOCK_ROOT\"] = options.rootDir;\n if (options?.spockBin) env[\"SPOCK_BIN\"] = options.spockBin;\n return {\n test: {\n env,\n setupFiles: [\"vitest-spock/node/setup\"],\n },\n };\n },\n };\n}\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/node/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAA0B,MAAM,aAAa,CAAC;AA0B1E,SAAS,WAAW,CAAC,KAAyB;IAC5C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACvE,OAAO,KAAK;SACT,KAAK,CAAC,GAAG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AG,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;YAC9D,IAAI,OAAO,EAAE,iBAAiB;gBAAE,GAAG,CAAC,kCAAkC,CAAC,GAAG,GAAG,CAAC;YAC9E,IAAI,OAAO,EAAE,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjE,GAAG,CAAC,8BAA8B,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzE,CAAC;YACD,IAAI,OAAO,EAAE,gBAAgB;gBAAE,GAAG,CAAC,iCAAiC,CAAC,GAAG,GAAG,CAAC;YAC5E,IAAI,OAAO,EAAE,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/D,GAAG,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvE,CAAC;YACD,IAAI,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,CAAC;gBACvC,GAAG,CAAC,2BAA2B,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACjE,CAAC;YACD,OAAO;gBACL,IAAI,EAAE;oBACJ,GAAG;oBACH,UAAU,EAAE,CAAC,yBAAyB,CAAC;iBACxC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { autoVerifyConsole } from \"../auto.js\";\nimport { registerSpockMatchers, registerSpockTransport } from \"../matcher.js\";\nimport { createNodeTransport, type NodeRunnerOptions } from \"./runner.js\";\n\nexport type SpockPluginOptions = NodeRunnerOptions &\n Readonly<{\n /**\n * When `true` alongside `spec`, automatically installs `autoVerifyConsole` in every\n * Vitest test so existing structured `console.log` JSON logs are checked against `spec`\n * with zero changes to app code or test bodies.\n */\n captureConsole?: boolean | undefined;\n /** `.spock` specification path used when `captureConsole` is enabled. */\n spec?: string | undefined;\n /** Optional model name inside `spec` used when `captureConsole` is enabled. */\n model?: string | undefined;\n /** Require every leaf action reachable from `model.next` across the suite. */\n requireAllActions?: boolean | undefined;\n /** Suite-level required action names checked in `afterAll`. */\n requireActions?: readonly string[] | undefined;\n /** Require every `State` field to be observed across the suite. */\n requireAllFields?: boolean | undefined;\n /** Suite-level required observed field names checked in `afterAll`. */\n requireFields?: readonly string[] | undefined;\n /** Suite-level maximum pure stutter observations checked in `afterAll`. */\n maxStutters?: number | undefined;\n }>;\n\nfunction parseCsvEnv(value: string | undefined): string[] | undefined {\n if (value === undefined || value.trim().length === 0) return undefined;\n return value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\n/**\n * Configure `vitest-spock` for a Node Vitest environment: registers the local `spock` CLI\n * transport and Vitest's `toConformTo` matcher. If `captureConsole` (or\n * `VITEST_SPOCK_CAPTURE_CONSOLE=1` + `VITEST_SPOCK_SPEC`) is set, also hooks `console`\n * automatically via [`autoVerifyConsole`].\n */\nexport function setupNodeSpock(options?: SpockPluginOptions | undefined): void {\n const rootDir = options?.rootDir ?? process.env[\"VITEST_SPOCK_ROOT\"] ?? process.cwd();\n const spockBin = options?.spockBin ?? process.env[\"SPOCK_BIN\"];\n registerSpockTransport(\n createNodeTransport({\n rootDir,\n spockBin,\n onMissingBinary: options?.onMissingBinary,\n timeoutMs: options?.timeoutMs,\n }),\n );\n registerSpockMatchers();\n\n const autoCapture =\n options?.captureConsole ?? process.env[\"VITEST_SPOCK_CAPTURE_CONSOLE\"] === \"1\";\n const spec = options?.spec ?? process.env[\"VITEST_SPOCK_SPEC\"];\n if (autoCapture && spec !== undefined && spec.length > 0) {\n const rawMaxStutters = process.env[\"VITEST_SPOCK_MAX_STUTTERS\"];\n const maxStutters =\n options?.maxStutters ??\n (rawMaxStutters !== undefined && rawMaxStutters.length > 0\n ? Number.parseInt(rawMaxStutters, 10)\n : undefined);\n autoVerifyConsole({\n spec,\n model: options?.model ?? process.env[\"VITEST_SPOCK_MODEL\"],\n requireAllActions:\n options?.requireAllActions ?? process.env[\"VITEST_SPOCK_REQUIRE_ALL_ACTIONS\"] === \"1\",\n requireActions:\n options?.requireActions ?? parseCsvEnv(process.env[\"VITEST_SPOCK_REQUIRE_ACTIONS\"]),\n requireAllFields:\n options?.requireAllFields ?? process.env[\"VITEST_SPOCK_REQUIRE_ALL_FIELDS\"] === \"1\",\n requireFields:\n options?.requireFields ?? parseCsvEnv(process.env[\"VITEST_SPOCK_REQUIRE_FIELDS\"]),\n maxStutters: Number.isNaN(maxStutters) ? undefined : maxStutters,\n timeoutMs: options?.timeoutMs,\n onMissingBinary: options?.onMissingBinary,\n });\n }\n}\n\n/**\n * Minimal Vite/Vitest plugin for Node projects. Exports `VITEST_SPOCK_ROOT` (and `SPOCK_BIN`\n * / auto-capture settings when specified) and registers `vitest-spock/node/setup` in\n * `test.setupFiles`.\n */\nexport function spock(options?: SpockPluginOptions | undefined): {\n name: string;\n config(): Record<string, unknown>;\n} {\n return {\n name: \"vitest-spock\",\n config() {\n const env: Record<string, string> = {};\n if (options?.rootDir) env[\"VITEST_SPOCK_ROOT\"] = options.rootDir;\n if (options?.spockBin) env[\"SPOCK_BIN\"] = options.spockBin;\n if (options?.captureConsole) env[\"VITEST_SPOCK_CAPTURE_CONSOLE\"] = \"1\";\n if (options?.spec) env[\"VITEST_SPOCK_SPEC\"] = options.spec;\n if (options?.model) env[\"VITEST_SPOCK_MODEL\"] = options.model;\n if (options?.requireAllActions) env[\"VITEST_SPOCK_REQUIRE_ALL_ACTIONS\"] = \"1\";\n if (options?.requireActions && options.requireActions.length > 0) {\n env[\"VITEST_SPOCK_REQUIRE_ACTIONS\"] = options.requireActions.join(\",\");\n }\n if (options?.requireAllFields) env[\"VITEST_SPOCK_REQUIRE_ALL_FIELDS\"] = \"1\";\n if (options?.requireFields && options.requireFields.length > 0) {\n env[\"VITEST_SPOCK_REQUIRE_FIELDS\"] = options.requireFields.join(\",\");\n }\n if (options?.maxStutters !== undefined) {\n env[\"VITEST_SPOCK_MAX_STUTTERS\"] = String(options.maxStutters);\n }\n return {\n test: {\n env,\n setupFiles: [\"vitest-spock/node/setup\"],\n },\n };\n },\n };\n}\n"]}
package/dist/trace.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import type { SpockSession, Trace, TraceInput, TraceLine, TraceState } from "./types.js";
2
- /** Serialize trace lines to NDJSON expected by `spock trace`. */
2
+ /**
3
+ * Validates that a `TraceLine` contains no `NaN`, `±Infinity`, `undefined`, `function`, or
4
+ * `symbol` values inside `state` or `args`, preventing JS `JSON.stringify` from silently
5
+ * turning broken runtime values into `null` or omitted wildcards.
6
+ */
7
+ export declare function validateTraceLine(line: TraceLine, lineNumber?: number): void;
8
+ /** Serialize trace lines to NDJSON expected by `spock trace`, rejecting non-JSON runtime values. */
3
9
  export declare function toNdjson(lines: readonly TraceLine[]): string;
4
10
  /** Type guard for a live host-collected `SpockSession`. */
5
11
  export declare function isSpockSession(value: unknown): value is SpockSession;
package/dist/trace.js CHANGED
@@ -1,8 +1,49 @@
1
- /** Serialize trace lines to NDJSON expected by `spock trace`. */
1
+ function assertValidTraceValue(value, path, lineNumber) {
2
+ const where = lineNumber !== undefined ? `trace line ${lineNumber} (${path})` : path;
3
+ if (value === undefined) {
4
+ throw new TypeError(`vitest-spock: ${where} is undefined (JSON.stringify would drop it and spock trace treats missing fields as wildcards)`);
5
+ }
6
+ if (typeof value === "number" && !Number.isFinite(value)) {
7
+ throw new RangeError(`vitest-spock: ${where} is ${String(value)} (JSON.stringify would encode it as null and spock trace treats null as a wildcard)`);
8
+ }
9
+ if (typeof value === "function" || typeof value === "symbol") {
10
+ throw new TypeError(`vitest-spock: ${where} is a ${typeof value}, which cannot be serialized to a spock trace`);
11
+ }
12
+ if (Array.isArray(value)) {
13
+ for (let i = 0; i < value.length; i += 1) {
14
+ assertValidTraceValue(value[i], `${path}[${i}]`, lineNumber);
15
+ }
16
+ return;
17
+ }
18
+ if (typeof value === "object" && value !== null) {
19
+ for (const key of Object.keys(value)) {
20
+ assertValidTraceValue(value[key], `${path}.${key}`, lineNumber);
21
+ }
22
+ }
23
+ }
24
+ /**
25
+ * Validates that a `TraceLine` contains no `NaN`, `±Infinity`, `undefined`, `function`, or
26
+ * `symbol` values inside `state` or `args`, preventing JS `JSON.stringify` from silently
27
+ * turning broken runtime values into `null` or omitted wildcards.
28
+ */
29
+ export function validateTraceLine(line, lineNumber) {
30
+ if (line.args !== undefined) {
31
+ assertValidTraceValue(line.args, "args", lineNumber);
32
+ }
33
+ if (line.state !== undefined) {
34
+ assertValidTraceValue(line.state, "state", lineNumber);
35
+ }
36
+ }
37
+ /** Serialize trace lines to NDJSON expected by `spock trace`, rejecting non-JSON runtime values. */
2
38
  export function toNdjson(lines) {
3
39
  if (lines.length === 0)
4
40
  return "";
5
- return `${lines.map((line) => JSON.stringify(line)).join("\n")}\n`;
41
+ return `${lines
42
+ .map((line, i) => {
43
+ validateTraceLine(line, i + 1);
44
+ return JSON.stringify(line);
45
+ })
46
+ .join("\n")}\n`;
6
47
  }
7
48
  /** Type guard for a live host-collected `SpockSession`. */
8
49
  export function isSpockSession(value) {
package/dist/trace.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CAAC,KAA2B;IAClD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACrE,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,gBAAgB,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,IAAI,CAAC;QACd,CAAC;QACD,4CAA4C;QAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAyB,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,KAAiB;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAe;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,YAAqC;IAC/D,OAAO,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { SpockSession, Trace, TraceArgs, TraceInput, TraceLine, TraceState } from \"./types.js\";\n\n/** Serialize trace lines to NDJSON expected by `spock trace`. */\nexport function toNdjson(lines: readonly TraceLine[]): string {\n if (lines.length === 0) return \"\";\n return `${lines.map((line) => JSON.stringify(line)).join(\"\\n\")}\\n`;\n}\n\n/** Type guard for a live host-collected `SpockSession`. */\nexport function isSpockSession(value: unknown): value is SpockSession {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__spockSession\" in value &&\n (value as { __spockSession?: unknown }).__spockSession === true\n );\n}\n\n/** Type guard for a `Trace` builder created by `createTrace()`. */\nexport function isTraceBuilder(value: unknown): value is Trace {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"toNdjson\" in value &&\n typeof (value as { toNdjson?: unknown }).toNdjson === \"function\" &&\n \"lines\" in value &&\n typeof (value as { lines?: unknown }).lines === \"function\"\n );\n}\n\n/** Convert a `Trace`, `TraceLine[]`, or raw NDJSON string into `{ ndjson, lines }`. */\nexport function normalizeTraceInput(input: Exclude<TraceInput, SpockSession>): {\n ndjson: string;\n lines: readonly TraceLine[];\n} {\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n const lines: TraceLine[] = [];\n if (trimmed.length > 0) {\n for (const raw of trimmed.split(/\\r?\\n/)) {\n if (raw.trim().length === 0) continue;\n try {\n lines.push(JSON.parse(raw) as TraceLine);\n } catch {\n // Leave parse errors to `spock trace`, which reports exact line numbers.\n }\n }\n }\n return { ndjson: trimmed.length === 0 ? \"\" : `${trimmed}\\n`, lines };\n }\n if (isTraceBuilder(input)) {\n const lines = input.lines();\n return { ndjson: toNdjson(lines), lines };\n }\n if (Array.isArray(input)) {\n return { ndjson: toNdjson(input), lines: input };\n }\n throw new TypeError(\n \"Expected a Trace (from createTrace()), SpockSession, TraceLine[], or NDJSON string\",\n );\n}\n\nclass TraceBuilder implements Trace {\n readonly #lines: TraceLine[] = [];\n\n constructor(initialState?: TraceState | undefined) {\n if (initialState !== undefined) {\n this.#lines.push({ state: initialState });\n }\n }\n\n init(state: TraceState): this {\n this.#lines.push({ state });\n return this;\n }\n\n step(\n action: string,\n argsOrState?: TraceArgs | TraceState | undefined,\n state?: TraceState | undefined,\n ): this {\n if (argsOrState === undefined) {\n this.#lines.push(state === undefined ? { action } : { action, state });\n return this;\n }\n if (Array.isArray(argsOrState)) {\n const line: TraceLine =\n state === undefined\n ? { action, args: argsOrState }\n : { action, args: argsOrState, state };\n this.#lines.push(line);\n return this;\n }\n // `argsOrState` is a state snapshot object.\n this.#lines.push({ action, state: argsOrState as TraceState });\n return this;\n }\n\n saw(state: TraceState): this {\n this.#lines.push({ state });\n return this;\n }\n\n push(line: TraceLine): this {\n this.#lines.push(line);\n return this;\n }\n\n lines(): readonly TraceLine[] {\n return [...this.#lines];\n }\n\n toNdjson(): string {\n return toNdjson(this.#lines);\n }\n\n get length(): number {\n return this.#lines.length;\n }\n\n clear(): this {\n this.#lines.length = 0;\n return this;\n }\n}\n\n/**\n * Create an in-memory trace recorder for conformance testing against a `.spock` spec.\n *\n * Optionally pass `initialState` to immediately record line 1 (`{ state: initialState }`).\n */\nexport function createTrace(initialState?: TraceState | undefined): Trace {\n return new TraceBuilder(initialState);\n}\n"]}
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAqB,CAAC,KAAc,EAAE,IAAY,EAAE,UAAmB;IAC9E,MAAM,KAAK,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,UAAU,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACrF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,SAAS,CACjB,iBAAiB,KAAK,iGAAiG,CACxH,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,UAAU,CAClB,iBAAiB,KAAK,OAAO,MAAM,CAAC,KAAK,CAAC,qFAAqF,CAChI,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC7D,MAAM,IAAI,SAAS,CACjB,iBAAiB,KAAK,SAAS,OAAO,KAAK,+CAA+C,CAC3F,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAA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E;gBAC/B,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,4CAA4C;QAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAyB,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,KAAiB;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAe;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,YAAqC;IAC/D,OAAO,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { SpockSession, Trace, TraceArgs, TraceInput, TraceLine, TraceState } from \"./types.js\";\n\nfunction assertValidTraceValue(value: unknown, path: string, lineNumber?: number): void {\n const where = lineNumber !== undefined ? `trace line ${lineNumber} (${path})` : path;\n if (value === undefined) {\n throw new TypeError(\n `vitest-spock: ${where} is undefined (JSON.stringify would drop it and spock trace treats missing fields as wildcards)`,\n );\n }\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n throw new RangeError(\n `vitest-spock: ${where} is ${String(value)} (JSON.stringify would encode it as null and spock trace treats null as a wildcard)`,\n );\n }\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n throw new TypeError(\n `vitest-spock: ${where} is a ${typeof value}, which cannot be serialized to a spock trace`,\n );\n }\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i += 1) {\n assertValidTraceValue(value[i], `${path}[${i}]`, lineNumber);\n }\n return;\n }\n if (typeof value === \"object\" && value !== null) {\n for (const key of Object.keys(value as Record<string, unknown>)) {\n assertValidTraceValue((value as Record<string, unknown>)[key], `${path}.${key}`, lineNumber);\n }\n }\n}\n\n/**\n * Validates that a `TraceLine` contains no `NaN`, `±Infinity`, `undefined`, `function`, or\n * `symbol` values inside `state` or `args`, preventing JS `JSON.stringify` from silently\n * turning broken runtime values into `null` or omitted wildcards.\n */\nexport function validateTraceLine(line: TraceLine, lineNumber?: number): void {\n if (line.args !== undefined) {\n assertValidTraceValue(line.args, \"args\", lineNumber);\n }\n if (line.state !== undefined) {\n assertValidTraceValue(line.state, \"state\", lineNumber);\n }\n}\n\n/** Serialize trace lines to NDJSON expected by `spock trace`, rejecting non-JSON runtime values. */\nexport function toNdjson(lines: readonly TraceLine[]): string {\n if (lines.length === 0) return \"\";\n return `${lines\n .map((line, i) => {\n validateTraceLine(line, i + 1);\n return JSON.stringify(line);\n })\n .join(\"\\n\")}\\n`;\n}\n\n/** Type guard for a live host-collected `SpockSession`. */\nexport function isSpockSession(value: unknown): value is SpockSession {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__spockSession\" in value &&\n (value as { __spockSession?: unknown }).__spockSession === true\n );\n}\n\n/** Type guard for a `Trace` builder created by `createTrace()`. */\nexport function isTraceBuilder(value: unknown): value is Trace {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"toNdjson\" in value &&\n typeof (value as { toNdjson?: unknown }).toNdjson === \"function\" &&\n \"lines\" in value &&\n typeof (value as { lines?: unknown }).lines === \"function\"\n );\n}\n\n/** Convert a `Trace`, `TraceLine[]`, or raw NDJSON string into `{ ndjson, lines }`. */\nexport function normalizeTraceInput(input: Exclude<TraceInput, SpockSession>): {\n ndjson: string;\n lines: readonly TraceLine[];\n} {\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n const lines: TraceLine[] = [];\n if (trimmed.length > 0) {\n for (const raw of trimmed.split(/\\r?\\n/)) {\n if (raw.trim().length === 0) continue;\n try {\n lines.push(JSON.parse(raw) as TraceLine);\n } catch {\n // Leave parse errors to `spock trace`, which reports exact line numbers.\n }\n }\n }\n return { ndjson: trimmed.length === 0 ? \"\" : `${trimmed}\\n`, lines };\n }\n if (isTraceBuilder(input)) {\n const lines = input.lines();\n return { ndjson: toNdjson(lines), lines };\n }\n if (Array.isArray(input)) {\n return { ndjson: toNdjson(input), lines: input };\n }\n throw new TypeError(\n \"Expected a Trace (from createTrace()), SpockSession, TraceLine[], or NDJSON string\",\n );\n}\n\nclass TraceBuilder implements Trace {\n readonly #lines: TraceLine[] = [];\n\n constructor(initialState?: TraceState | undefined) {\n if (initialState !== undefined) {\n this.#lines.push({ state: initialState });\n }\n }\n\n init(state: TraceState): this {\n this.#lines.push({ state });\n return this;\n }\n\n step(\n action: string,\n argsOrState?: TraceArgs | TraceState | undefined,\n state?: TraceState | undefined,\n ): this {\n if (argsOrState === undefined) {\n this.#lines.push(state === undefined ? { action } : { action, state });\n return this;\n }\n if (Array.isArray(argsOrState)) {\n const line: TraceLine =\n state === undefined\n ? { action, args: argsOrState }\n : { action, args: argsOrState, state };\n this.#lines.push(line);\n return this;\n }\n // `argsOrState` is a state snapshot object.\n this.#lines.push({ action, state: argsOrState as TraceState });\n return this;\n }\n\n saw(state: TraceState): this {\n this.#lines.push({ state });\n return this;\n }\n\n push(line: TraceLine): this {\n this.#lines.push(line);\n return this;\n }\n\n lines(): readonly TraceLine[] {\n return [...this.#lines];\n }\n\n toNdjson(): string {\n return toNdjson(this.#lines);\n }\n\n get length(): number {\n return this.#lines.length;\n }\n\n clear(): this {\n this.#lines.length = 0;\n return this;\n }\n}\n\n/**\n * Create an in-memory trace recorder for conformance testing against a `.spock` spec.\n *\n * Optionally pass `initialState` to immediately record line 1 (`{ state: initialState }`).\n */\nexport function createTrace(initialState?: TraceState | undefined): Trace {\n return new TraceBuilder(initialState);\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -49,9 +49,22 @@ export type TraceMiss = Readonly<{
49
49
  from: TraceStep | null;
50
50
  why: TraceWhy;
51
51
  }>;
52
+ /** Coverage summary emitted by `spock trace --json` on conforming traces. */
53
+ export type TraceCoverageSummary = Readonly<{
54
+ actions: readonly string[];
55
+ leaf_actions: readonly string[];
56
+ missing_actions: readonly string[];
57
+ observed_fields: readonly string[];
58
+ spec_fields: readonly string[];
59
+ missing_fields: readonly string[];
60
+ stutters: number;
61
+ }>;
52
62
  /** Discriminated outcome of `spock trace --json`. */
53
63
  export type TraceOutcome = Readonly<{
54
64
  kind: "matches";
65
+ }> | Readonly<{
66
+ kind: "coverage";
67
+ errors: readonly string[];
55
68
  }> | Readonly<{
56
69
  kind: "invariant";
57
70
  name: string;
@@ -86,9 +99,49 @@ export type TraceReport = Readonly<{
86
99
  generated: number;
87
100
  seconds: number;
88
101
  behavior: readonly MatchedStep[];
102
+ coverage?: TraceCoverageSummary | undefined;
89
103
  }>;
90
104
  /** Policy when the `spock` CLI binary cannot be located on the host. */
91
105
  export type MissingBinaryPolicy = "fail" | "skip";
106
+ /** Coverage requirements enforced against one trace or a suite tracker. */
107
+ export type CoverageRequirement = Readonly<{
108
+ /** Require every leaf action reachable from `model.next` to be exercised. */
109
+ requireAllActions?: boolean | undefined;
110
+ /** Action names that must be exercised (matches `"State::foo"` or short `"foo"`). */
111
+ requireActions?: readonly string[] | undefined;
112
+ /** Require every field of `State` to be observed at least once. */
113
+ requireAllFields?: boolean | undefined;
114
+ /** Top-level `State` fields that must be observed at least once. */
115
+ requireFields?: readonly string[] | undefined;
116
+ /** Maximum allowed pure-stutter observations after `init`. */
117
+ maxStutters?: number | undefined;
118
+ }>;
119
+ /** Snapshot of exercised actions, observed state fields, and stutter count. */
120
+ export type CoverageSnapshot = Readonly<{
121
+ traces: number;
122
+ lines: number;
123
+ stutters: number;
124
+ actions: readonly string[];
125
+ leafActions: readonly string[];
126
+ fields: readonly string[];
127
+ specFields: readonly string[];
128
+ }>;
129
+ /** Result of evaluating a [`CoverageRequirement`]. */
130
+ export type CoverageResult = Readonly<{
131
+ ok: boolean;
132
+ missingActions: readonly string[];
133
+ missingFields: readonly string[];
134
+ stutters: number;
135
+ message: string;
136
+ }>;
137
+ /** Accumulates trace coverage across multiple tests in a suite. */
138
+ export interface CoverageTracker {
139
+ record(report: TraceReport, observedLines: readonly TraceLine[]): void;
140
+ snapshot(): CoverageSnapshot;
141
+ check(req: CoverageRequirement): CoverageResult;
142
+ assertCoverage(req: CoverageRequirement): void;
143
+ reset(): void;
144
+ }
92
145
  /** Options passed to `toConformTo` or `checkTrace`. */
93
146
  export type ConformOptions = Readonly<{
94
147
  /** Model name declared in the `.spock` file (`--model`). */
@@ -99,6 +152,18 @@ export type ConformOptions = Readonly<{
99
152
  onMissingBinary?: MissingBinaryPolicy | undefined;
100
153
  /** Clear a live `SpockSession` buffer after validating. Defaults to `false`. */
101
154
  clear?: boolean | undefined;
155
+ /** Require every leaf action reachable from `model.next` to fire in this trace. */
156
+ requireAllActions?: boolean | undefined;
157
+ /** Require each named action (short or `State::` qualified) to fire in this trace. */
158
+ requireActions?: readonly string[] | undefined;
159
+ /** Require every `State` field to be observed in this trace. */
160
+ requireAllFields?: boolean | undefined;
161
+ /** Require each named top-level `State` field to be observed in this trace. */
162
+ requireFields?: readonly string[] | undefined;
163
+ /** Fail if more than this many non-initial observations matched purely by stuttering. */
164
+ maxStutters?: number | undefined;
165
+ /** Optional suite-level tracker to record this conforming trace's coverage into. */
166
+ coverage?: CoverageTracker | undefined;
102
167
  }>;
103
168
  /** Fluent trace builder for tests. */
104
169
  export interface Trace {
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** A partial or complete snapshot of the spec's `State` fields. */\nexport type TraceState = Readonly<Record<string, unknown>>;\n\n/** Positional arguments for an action step, matching `spock trace` JSON encoding. */\nexport type TraceArgs = readonly unknown[];\n\n/** One NDJSON line accepted by `spock trace`. */\nexport type TraceLine = Readonly<{\n action?: string | undefined;\n args?: TraceArgs | undefined;\n state?: TraceState | undefined;\n}>;\n\n/** Source location reported by `spock` diagnostics. */\nexport type SpockLocation = Readonly<{\n file: string;\n line: number;\n column: number;\n}>;\n\n/** A single state step in a `spock` JSON trace or behavior. */\nexport type TraceStep = Readonly<{\n action: string | null;\n args: readonly unknown[];\n state: TraceState;\n}>;\n\n/** A matched step in a `spock trace --json` behavior. */\nexport type MatchedStep = Readonly<{\n line: number | null;\n action: string | null;\n args: readonly unknown[];\n state: TraceState;\n}>;\n\n/** A single field/path mismatch in a `differs` miss. */\nexport type TraceDifference = Readonly<{\n path: string;\n seen: unknown;\n spec: unknown;\n}>;\n\n/** Why a step failed to match from a reachable state. */\nexport type TraceWhy =\n | Readonly<{ kind: \"not_enabled\" }>\n | Readonly<{ kind: \"arguments\"; arguments: readonly (readonly unknown[])[] }>\n | Readonly<{\n kind: \"differs\";\n step: TraceStep | null;\n differences: readonly TraceDifference[];\n }>;\n\n/** One reachable-state failure explanation when a trace diverges. */\nexport type TraceMiss = Readonly<{\n from: TraceStep | null;\n why: TraceWhy;\n}>;\n\n/** Discriminated outcome of `spock trace --json`. */\nexport type TraceOutcome =\n | Readonly<{ kind: \"matches\" }>\n | Readonly<{ kind: \"invariant\"; name: string; line: number }>\n | Readonly<{ kind: \"step_property\"; name: string; line: number }>\n | Readonly<{ kind: \"diverges\"; line: number; misses: readonly TraceMiss[] }>\n | Readonly<{\n kind: \"error\";\n message: string;\n location: SpockLocation | null;\n line: number | null;\n }>\n | Readonly<{ kind: \"skipped\"; reason: string }>;\n\n/** Full JSON report emitted by `spock trace --json`. */\nexport type TraceReport = Readonly<{\n version: number;\n spec: string;\n model: string | null;\n trace: string;\n outcome: TraceOutcome;\n states: number;\n matched: number;\n most: number;\n generated: number;\n seconds: number;\n behavior: readonly MatchedStep[];\n}>;\n\n/** Policy when the `spock` CLI binary cannot be located on the host. */\nexport type MissingBinaryPolicy = \"fail\" | \"skip\";\n\n/** Options passed to `toConformTo` or `checkTrace`. */\nexport type ConformOptions = Readonly<{\n /** Model name declared in the `.spock` file (`--model`). */\n model?: string | undefined;\n /** Override timeout in milliseconds for the `spock trace` process. */\n timeoutMs?: number | undefined;\n /** Behavior when the `spock` binary is unavailable. Defaults to `\"fail\"`. */\n onMissingBinary?: MissingBinaryPolicy | undefined;\n /** Clear a live `SpockSession` buffer after validating. Defaults to `false`. */\n clear?: boolean | undefined;\n}>;\n\n/** Fluent trace builder for tests. */\nexport interface Trace {\n /** Record the initial state (or an unlabeled state observation). */\n init(state: TraceState): this;\n /**\n * Record an action step.\n *\n * Forms:\n * - `step(\"deliver_fail\")`\n * - `step(\"deliver_ok\", { status: \"Running\" })`\n * - `step(\"write\", [\"k1\", 42])`\n * - `step(\"write\", [\"k1\", 42], { seq: 1 })`\n */\n step(action: string, argsOrState?: TraceArgs | TraceState | undefined, state?: TraceState | undefined): this;\n /** Record an observation without naming an action (matches any step or stutter). */\n saw(state: TraceState): this;\n /** Append a raw `TraceLine`. */\n push(line: TraceLine): this;\n /** Return all recorded lines in order. */\n lines(): readonly TraceLine[];\n /** Serialize recorded lines as NDJSON (one JSON object per line). */\n toNdjson(): string;\n /** Number of recorded trace lines. */\n readonly length: number;\n /** Remove all recorded lines. */\n clear(): this;\n}\n\n/** Handle to a host-collected live session (e.g. emitted from Cloudflare Durable Objects). */\nexport interface SpockSession {\n readonly __spockSession: true;\n readonly name: string;\n /** Read all lines currently collected for this session. */\n lines(options?: Readonly<{ clear?: boolean | undefined }> | undefined): Promise<readonly TraceLine[]>;\n /** Reset/clear collected lines for this session. */\n clear(): Promise<void>;\n /** Validate this session directly against a `.spock` spec. */\n check(spec: string, options?: ConformOptions | undefined): Promise<TraceReport>;\n}\n\n/** Anything accepted by `expect(x).toConformTo(...)` and `checkTrace(x, ...)`. */\nexport type TraceInput = Trace | SpockSession | readonly TraceLine[] | string;\n\n/** Wire request sent from a test environment to a host `SpockTransport`. */\nexport type TraceCheckRequest = Readonly<{\n spec: string;\n model?: string | undefined;\n ndjson: string;\n timeoutMs?: number | undefined;\n onMissingBinary?: MissingBinaryPolicy | undefined;\n}>;\n\n/** Host transport that executes `spock trace` (Node directly or via Cloudflare service binding). */\nexport interface SpockTransport {\n readonly name: string;\n checkTrace(request: TraceCheckRequest): Promise<TraceReport>;\n checkSession?(\n session: string,\n spec: string,\n options?: ConformOptions | undefined,\n ): Promise<TraceReport>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** A partial or complete snapshot of the spec's `State` fields. */\nexport type TraceState = Readonly<Record<string, unknown>>;\n\n/** Positional arguments for an action step, matching `spock trace` JSON encoding. */\nexport type TraceArgs = readonly unknown[];\n\n/** One NDJSON line accepted by `spock trace`. */\nexport type TraceLine = Readonly<{\n action?: string | undefined;\n args?: TraceArgs | undefined;\n state?: TraceState | undefined;\n}>;\n\n/** Source location reported by `spock` diagnostics. */\nexport type SpockLocation = Readonly<{\n file: string;\n line: number;\n column: number;\n}>;\n\n/** A single state step in a `spock` JSON trace or behavior. */\nexport type TraceStep = Readonly<{\n action: string | null;\n args: readonly unknown[];\n state: TraceState;\n}>;\n\n/** A matched step in a `spock trace --json` behavior. */\nexport type MatchedStep = Readonly<{\n line: number | null;\n action: string | null;\n args: readonly unknown[];\n state: TraceState;\n}>;\n\n/** A single field/path mismatch in a `differs` miss. */\nexport type TraceDifference = Readonly<{\n path: string;\n seen: unknown;\n spec: unknown;\n}>;\n\n/** Why a step failed to match from a reachable state. */\nexport type TraceWhy =\n | Readonly<{ kind: \"not_enabled\" }>\n | Readonly<{ kind: \"arguments\"; arguments: readonly (readonly unknown[])[] }>\n | Readonly<{\n kind: \"differs\";\n step: TraceStep | null;\n differences: readonly TraceDifference[];\n }>;\n\n/** One reachable-state failure explanation when a trace diverges. */\nexport type TraceMiss = Readonly<{\n from: TraceStep | null;\n why: TraceWhy;\n}>;\n\n/** Coverage summary emitted by `spock trace --json` on conforming traces. */\nexport type TraceCoverageSummary = Readonly<{\n actions: readonly string[];\n leaf_actions: readonly string[];\n missing_actions: readonly string[];\n observed_fields: readonly string[];\n spec_fields: readonly string[];\n missing_fields: readonly string[];\n stutters: number;\n}>;\n\n/** Discriminated outcome of `spock trace --json`. */\nexport type TraceOutcome =\n | Readonly<{ kind: \"matches\" }>\n | Readonly<{ kind: \"coverage\"; errors: readonly string[] }>\n | Readonly<{ kind: \"invariant\"; name: string; line: number }>\n | Readonly<{ kind: \"step_property\"; name: string; line: number }>\n | Readonly<{ kind: \"diverges\"; line: number; misses: readonly TraceMiss[] }>\n | Readonly<{\n kind: \"error\";\n message: string;\n location: SpockLocation | null;\n line: number | null;\n }>\n | Readonly<{ kind: \"skipped\"; reason: string }>;\n\n/** Full JSON report emitted by `spock trace --json`. */\nexport type TraceReport = Readonly<{\n version: number;\n spec: string;\n model: string | null;\n trace: string;\n outcome: TraceOutcome;\n states: number;\n matched: number;\n most: number;\n generated: number;\n seconds: number;\n behavior: readonly MatchedStep[];\n coverage?: TraceCoverageSummary | undefined;\n}>;\n\n/** Policy when the `spock` CLI binary cannot be located on the host. */\nexport type MissingBinaryPolicy = \"fail\" | \"skip\";\n\n/** Coverage requirements enforced against one trace or a suite tracker. */\nexport type CoverageRequirement = Readonly<{\n /** Require every leaf action reachable from `model.next` to be exercised. */\n requireAllActions?: boolean | undefined;\n /** Action names that must be exercised (matches `\"State::foo\"` or short `\"foo\"`). */\n requireActions?: readonly string[] | undefined;\n /** Require every field of `State` to be observed at least once. */\n requireAllFields?: boolean | undefined;\n /** Top-level `State` fields that must be observed at least once. */\n requireFields?: readonly string[] | undefined;\n /** Maximum allowed pure-stutter observations after `init`. */\n maxStutters?: number | undefined;\n}>;\n\n/** Snapshot of exercised actions, observed state fields, and stutter count. */\nexport type CoverageSnapshot = Readonly<{\n traces: number;\n lines: number;\n stutters: number;\n actions: readonly string[];\n leafActions: readonly string[];\n fields: readonly string[];\n specFields: readonly string[];\n}>;\n\n/** Result of evaluating a [`CoverageRequirement`]. */\nexport type CoverageResult = Readonly<{\n ok: boolean;\n missingActions: readonly string[];\n missingFields: readonly string[];\n stutters: number;\n message: string;\n}>;\n\n/** Accumulates trace coverage across multiple tests in a suite. */\nexport interface CoverageTracker {\n record(report: TraceReport, observedLines: readonly TraceLine[]): void;\n snapshot(): CoverageSnapshot;\n check(req: CoverageRequirement): CoverageResult;\n assertCoverage(req: CoverageRequirement): void;\n reset(): void;\n}\n\n/** Options passed to `toConformTo` or `checkTrace`. */\nexport type ConformOptions = Readonly<{\n /** Model name declared in the `.spock` file (`--model`). */\n model?: string | undefined;\n /** Override timeout in milliseconds for the `spock trace` process. */\n timeoutMs?: number | undefined;\n /** Behavior when the `spock` binary is unavailable. Defaults to `\"fail\"`. */\n onMissingBinary?: MissingBinaryPolicy | undefined;\n /** Clear a live `SpockSession` buffer after validating. Defaults to `false`. */\n clear?: boolean | undefined;\n /** Require every leaf action reachable from `model.next` to fire in this trace. */\n requireAllActions?: boolean | undefined;\n /** Require each named action (short or `State::` qualified) to fire in this trace. */\n requireActions?: readonly string[] | undefined;\n /** Require every `State` field to be observed in this trace. */\n requireAllFields?: boolean | undefined;\n /** Require each named top-level `State` field to be observed in this trace. */\n requireFields?: readonly string[] | undefined;\n /** Fail if more than this many non-initial observations matched purely by stuttering. */\n maxStutters?: number | undefined;\n /** Optional suite-level tracker to record this conforming trace's coverage into. */\n coverage?: CoverageTracker | undefined;\n}>;\n\n/** Fluent trace builder for tests. */\nexport interface Trace {\n /** Record the initial state (or an unlabeled state observation). */\n init(state: TraceState): this;\n /**\n * Record an action step.\n *\n * Forms:\n * - `step(\"deliver_fail\")`\n * - `step(\"deliver_ok\", { status: \"Running\" })`\n * - `step(\"write\", [\"k1\", 42])`\n * - `step(\"write\", [\"k1\", 42], { seq: 1 })`\n */\n step(action: string, argsOrState?: TraceArgs | TraceState | undefined, state?: TraceState | undefined): this;\n /** Record an observation without naming an action (matches any step or stutter). */\n saw(state: TraceState): this;\n /** Append a raw `TraceLine`. */\n push(line: TraceLine): this;\n /** Return all recorded lines in order. */\n lines(): readonly TraceLine[];\n /** Serialize recorded lines as NDJSON (one JSON object per line). */\n toNdjson(): string;\n /** Number of recorded trace lines. */\n readonly length: number;\n /** Remove all recorded lines. */\n clear(): this;\n}\n\n/** Handle to a host-collected live session (e.g. emitted from Cloudflare Durable Objects). */\nexport interface SpockSession {\n readonly __spockSession: true;\n readonly name: string;\n /** Read all lines currently collected for this session. */\n lines(options?: Readonly<{ clear?: boolean | undefined }> | undefined): Promise<readonly TraceLine[]>;\n /** Reset/clear collected lines for this session. */\n clear(): Promise<void>;\n /** Validate this session directly against a `.spock` spec. */\n check(spec: string, options?: ConformOptions | undefined): Promise<TraceReport>;\n}\n\n/** Anything accepted by `expect(x).toConformTo(...)` and `checkTrace(x, ...)`. */\nexport type TraceInput = Trace | SpockSession | readonly TraceLine[] | string;\n\n/** Wire request sent from a test environment to a host `SpockTransport`. */\nexport type TraceCheckRequest = Readonly<{\n spec: string;\n model?: string | undefined;\n ndjson: string;\n timeoutMs?: number | undefined;\n onMissingBinary?: MissingBinaryPolicy | undefined;\n}>;\n\n/** Host transport that executes `spock trace` (Node directly or via Cloudflare service binding). */\nexport interface SpockTransport {\n readonly name: string;\n checkTrace(request: TraceCheckRequest): Promise<TraceReport>;\n checkSession?(\n session: string,\n spec: string,\n options?: ConformOptions | undefined,\n ): Promise<TraceReport>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-spock",
3
- "version": "0.6.0",
3
+ "version": "0.10.0",
4
4
  "description": "Vitest matchers, trace recorder, and Cloudflare Workers / Durable Objects bridge for spock trace conformance",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -54,6 +54,17 @@
54
54
  "README.md",
55
55
  "LICENSE"
56
56
  ],
57
+ "scripts": {
58
+ "build": "tsc -p tsconfig.json",
59
+ "prepack": "npm run build",
60
+ "typecheck": "tsc -p tsconfig.json --noEmit",
61
+ "test": "npm run build && vitest run"
62
+ },
63
+ "devDependencies": {
64
+ "@types/node": "^22.0.0",
65
+ "typescript": "^5.8.0",
66
+ "vitest": "^4.1.0"
67
+ },
57
68
  "peerDependencies": {
58
69
  "vitest": ">=2.0.0"
59
70
  },