@vitest-agent/mcp 1.1.0 → 1.3.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.
Files changed (209) hide show
  1. package/README.md +1 -2
  2. package/index.d.ts +3 -2
  3. package/index.js +1 -1
  4. package/package.json +1 -1
  5. package/server.js +2 -4
  6. package/tools/run-tests.js +17 -3
  7. package/patterns/_meta.json +0 -67
  8. package/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
  9. package/patterns/known-issues-and-caveats.md +0 -52
  10. package/patterns/operating-vitest-agent-as-an-agent.md +0 -62
  11. package/patterns/running-tests-via-mcp.md +0 -103
  12. package/patterns/silencing-leaking-output-in-tests.md +0 -91
  13. package/patterns/testing-effect-schema-definitions.md +0 -71
  14. package/patterns/testing-effect-services-with-mock-layers.md +0 -63
  15. package/resources/index.js +0 -166
  16. package/resources/indexes.js +0 -77
  17. package/resources/manifest-schema.js +0 -46
  18. package/resources/paths.js +0 -20
  19. package/resources/patterns.js +0 -22
  20. package/resources/upstream-docs.js +0 -22
  21. package/vendor/vitest-docs/ATTRIBUTION.md +0 -5
  22. package/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
  23. package/vendor/vitest-docs/api/advanced/metadata.md +0 -68
  24. package/vendor/vitest-docs/api/advanced/plugin.md +0 -168
  25. package/vendor/vitest-docs/api/advanced/reporters.md +0 -342
  26. package/vendor/vitest-docs/api/advanced/runner.md +0 -334
  27. package/vendor/vitest-docs/api/advanced/test-case.md +0 -302
  28. package/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
  29. package/vendor/vitest-docs/api/advanced/test-module.md +0 -140
  30. package/vendor/vitest-docs/api/advanced/test-project.md +0 -321
  31. package/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
  32. package/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
  33. package/vendor/vitest-docs/api/advanced/vitest.md +0 -684
  34. package/vendor/vitest-docs/api/assert-type.md +0 -22
  35. package/vendor/vitest-docs/api/assert.md +0 -1960
  36. package/vendor/vitest-docs/api/browser/assertions.md +0 -1277
  37. package/vendor/vitest-docs/api/browser/commands.md +0 -154
  38. package/vendor/vitest-docs/api/browser/context.md +0 -338
  39. package/vendor/vitest-docs/api/browser/interactivity.md +0 -681
  40. package/vendor/vitest-docs/api/browser/locators.md +0 -1171
  41. package/vendor/vitest-docs/api/browser/react.md +0 -346
  42. package/vendor/vitest-docs/api/browser/svelte.md +0 -292
  43. package/vendor/vitest-docs/api/browser/vue.md +0 -222
  44. package/vendor/vitest-docs/api/describe.md +0 -374
  45. package/vendor/vitest-docs/api/expect-typeof.md +0 -571
  46. package/vendor/vitest-docs/api/expect.md +0 -2304
  47. package/vendor/vitest-docs/api/hooks.md +0 -463
  48. package/vendor/vitest-docs/api/mock.md +0 -701
  49. package/vendor/vitest-docs/api/test.md +0 -926
  50. package/vendor/vitest-docs/api/vi.md +0 -1372
  51. package/vendor/vitest-docs/config/alias.md +0 -13
  52. package/vendor/vitest-docs/config/allowonly.md +0 -32
  53. package/vendor/vitest-docs/config/api.md +0 -27
  54. package/vendor/vitest-docs/config/attachmentsdir.md +0 -6
  55. package/vendor/vitest-docs/config/bail.md +0 -9
  56. package/vendor/vitest-docs/config/benchmark.md +0 -65
  57. package/vendor/vitest-docs/config/browser/api.md +0 -23
  58. package/vendor/vitest-docs/config/browser/commands.md +0 -6
  59. package/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
  60. package/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
  61. package/vendor/vitest-docs/config/browser/enabled.md +0 -40
  62. package/vendor/vitest-docs/config/browser/expect.md +0 -250
  63. package/vendor/vitest-docs/config/browser/headless.md +0 -7
  64. package/vendor/vitest-docs/config/browser/instances.md +0 -47
  65. package/vendor/vitest-docs/config/browser/isolate.md +0 -11
  66. package/vendor/vitest-docs/config/browser/locators.md +0 -24
  67. package/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
  68. package/vendor/vitest-docs/config/browser/playwright.md +0 -214
  69. package/vendor/vitest-docs/config/browser/preview.md +0 -32
  70. package/vendor/vitest-docs/config/browser/provider.md +0 -79
  71. package/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
  72. package/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
  73. package/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
  74. package/vendor/vitest-docs/config/browser/trace.md +0 -43
  75. package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
  76. package/vendor/vitest-docs/config/browser/ui.md +0 -7
  77. package/vendor/vitest-docs/config/browser/viewport.md +0 -6
  78. package/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
  79. package/vendor/vitest-docs/config/cache.md +0 -26
  80. package/vendor/vitest-docs/config/chaiconfig.md +0 -29
  81. package/vendor/vitest-docs/config/clearmocks.md +0 -22
  82. package/vendor/vitest-docs/config/coverage.md +0 -455
  83. package/vendor/vitest-docs/config/css.md +0 -47
  84. package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
  85. package/vendor/vitest-docs/config/deps.md +0 -127
  86. package/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
  87. package/vendor/vitest-docs/config/diff.md +0 -96
  88. package/vendor/vitest-docs/config/dir.md +0 -7
  89. package/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
  90. package/vendor/vitest-docs/config/env.md +0 -5
  91. package/vendor/vitest-docs/config/environment.md +0 -96
  92. package/vendor/vitest-docs/config/environmentoptions.md +0 -30
  93. package/vendor/vitest-docs/config/exclude.md +0 -49
  94. package/vendor/vitest-docs/config/execargv.md +0 -10
  95. package/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
  96. package/vendor/vitest-docs/config/expect.md +0 -38
  97. package/vendor/vitest-docs/config/experimental.md +0 -510
  98. package/vendor/vitest-docs/config/faketimers.md +0 -51
  99. package/vendor/vitest-docs/config/fileparallelism.md +0 -11
  100. package/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
  101. package/vendor/vitest-docs/config/globals.md +0 -42
  102. package/vendor/vitest-docs/config/globalsetup.md +0 -72
  103. package/vendor/vitest-docs/config/hideskippedtests.md +0 -7
  104. package/vendor/vitest-docs/config/hooktimeout.md +0 -7
  105. package/vendor/vitest-docs/config/include-source.md +0 -115
  106. package/vendor/vitest-docs/config/include.md +0 -71
  107. package/vendor/vitest-docs/config/includetasklocation.md +0 -17
  108. package/vendor/vitest-docs/config/index.md +0 -85
  109. package/vendor/vitest-docs/config/isolate.md +0 -13
  110. package/vendor/vitest-docs/config/logheapusage.md +0 -7
  111. package/vendor/vitest-docs/config/maxconcurrency.md +0 -9
  112. package/vendor/vitest-docs/config/maxworkers.md +0 -49
  113. package/vendor/vitest-docs/config/mockreset.md +0 -22
  114. package/vendor/vitest-docs/config/mode.md +0 -7
  115. package/vendor/vitest-docs/config/name.md +0 -111
  116. package/vendor/vitest-docs/config/onconsolelog.md +0 -25
  117. package/vendor/vitest-docs/config/onstacktrace.md +0 -32
  118. package/vendor/vitest-docs/config/onunhandlederror.md +0 -35
  119. package/vendor/vitest-docs/config/open.md +0 -7
  120. package/vendor/vitest-docs/config/outputfile.md +0 -7
  121. package/vendor/vitest-docs/config/passwithnotests.md +0 -7
  122. package/vendor/vitest-docs/config/pool.md +0 -45
  123. package/vendor/vitest-docs/config/printconsoletrace.md +0 -6
  124. package/vendor/vitest-docs/config/projects.md +0 -6
  125. package/vendor/vitest-docs/config/provide.md +0 -45
  126. package/vendor/vitest-docs/config/reporters.md +0 -69
  127. package/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
  128. package/vendor/vitest-docs/config/restoremocks.md +0 -22
  129. package/vendor/vitest-docs/config/retry.md +0 -140
  130. package/vendor/vitest-docs/config/root.md +0 -6
  131. package/vendor/vitest-docs/config/runner.md +0 -6
  132. package/vendor/vitest-docs/config/sequence.md +0 -158
  133. package/vendor/vitest-docs/config/server.md +0 -68
  134. package/vendor/vitest-docs/config/setupfiles.md +0 -40
  135. package/vendor/vitest-docs/config/silent.md +0 -9
  136. package/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
  137. package/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
  138. package/vendor/vitest-docs/config/snapshotformat.md +0 -28
  139. package/vendor/vitest-docs/config/snapshotserializers.md +0 -6
  140. package/vendor/vitest-docs/config/stricttags.md +0 -30
  141. package/vendor/vitest-docs/config/tags.md +0 -141
  142. package/vendor/vitest-docs/config/teardowntimeout.md +0 -7
  143. package/vendor/vitest-docs/config/testnamepattern.md +0 -21
  144. package/vendor/vitest-docs/config/testtimeout.md +0 -7
  145. package/vendor/vitest-docs/config/typecheck.md +0 -77
  146. package/vendor/vitest-docs/config/ui.md +0 -15
  147. package/vendor/vitest-docs/config/unstubenvs.md +0 -20
  148. package/vendor/vitest-docs/config/unstubglobals.md +0 -20
  149. package/vendor/vitest-docs/config/update.md +0 -16
  150. package/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
  151. package/vendor/vitest-docs/config/watch.md +0 -11
  152. package/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
  153. package/vendor/vitest-docs/guide/advanced/index.md +0 -147
  154. package/vendor/vitest-docs/guide/advanced/pool.md +0 -148
  155. package/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
  156. package/vendor/vitest-docs/guide/advanced/tests.md +0 -125
  157. package/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
  158. package/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
  159. package/vendor/vitest-docs/guide/browser/index.md +0 -630
  160. package/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
  161. package/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
  162. package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
  163. package/vendor/vitest-docs/guide/cli-generated.md +0 -972
  164. package/vendor/vitest-docs/guide/cli.md +0 -234
  165. package/vendor/vitest-docs/guide/common-errors.md +0 -163
  166. package/vendor/vitest-docs/guide/coverage.md +0 -515
  167. package/vendor/vitest-docs/guide/debugging.md +0 -127
  168. package/vendor/vitest-docs/guide/environment.md +0 -101
  169. package/vendor/vitest-docs/guide/extending-matchers.md +0 -160
  170. package/vendor/vitest-docs/guide/features.md +0 -310
  171. package/vendor/vitest-docs/guide/filtering.md +0 -175
  172. package/vendor/vitest-docs/guide/ide.md +0 -43
  173. package/vendor/vitest-docs/guide/improving-performance.md +0 -245
  174. package/vendor/vitest-docs/guide/in-source.md +0 -159
  175. package/vendor/vitest-docs/guide/index.md +0 -128
  176. package/vendor/vitest-docs/guide/learn/async.md +0 -147
  177. package/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
  178. package/vendor/vitest-docs/guide/learn/matchers.md +0 -277
  179. package/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
  180. package/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
  181. package/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
  182. package/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
  183. package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
  184. package/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
  185. package/vendor/vitest-docs/guide/lifecycle.md +0 -379
  186. package/vendor/vitest-docs/guide/migration.md +0 -863
  187. package/vendor/vitest-docs/guide/mocking/classes.md +0 -158
  188. package/vendor/vitest-docs/guide/mocking/dates.md +0 -52
  189. package/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
  190. package/vendor/vitest-docs/guide/mocking/functions.md +0 -61
  191. package/vendor/vitest-docs/guide/mocking/globals.md +0 -20
  192. package/vendor/vitest-docs/guide/mocking/modules.md +0 -414
  193. package/vendor/vitest-docs/guide/mocking/requests.md +0 -114
  194. package/vendor/vitest-docs/guide/mocking/timers.md +0 -48
  195. package/vendor/vitest-docs/guide/mocking.md +0 -239
  196. package/vendor/vitest-docs/guide/open-telemetry.md +0 -156
  197. package/vendor/vitest-docs/guide/parallelism.md +0 -82
  198. package/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
  199. package/vendor/vitest-docs/guide/projects.md +0 -291
  200. package/vendor/vitest-docs/guide/recipes.md +0 -59
  201. package/vendor/vitest-docs/guide/reporters.md +0 -723
  202. package/vendor/vitest-docs/guide/snapshot.md +0 -620
  203. package/vendor/vitest-docs/guide/test-annotations.md +0 -103
  204. package/vendor/vitest-docs/guide/test-context.md +0 -902
  205. package/vendor/vitest-docs/guide/test-tags.md +0 -314
  206. package/vendor/vitest-docs/guide/testing-types.md +0 -149
  207. package/vendor/vitest-docs/guide/ui.md +0 -160
  208. package/vendor/vitest-docs/guide/using-plugins.md +0 -5
  209. package/vendor/vitest-docs/manifest.json +0 -1691
package/README.md CHANGED
@@ -6,12 +6,11 @@
6
6
 
7
7
  > **Part of the [vitest-agent](https://vitest-agent.dev) ecosystem.** Most users want **[@vitest-agent/plugin](https://www.npmjs.com/package/@vitest-agent/plugin)**, which pulls this package in automatically. Install `@vitest-agent/mcp` directly only if you run the MCP server standalone.
8
8
 
9
- The `vitest-agent-mcp` MCP server bin. Exposes action-keyed tools over stdio that give LLM agents structured access to test data, coverage, history, failure signatures, TDD lifecycle state and more. Also surfaces four MCP resources (vendored Vitest docs and curated testing patterns) and six framing-only prompts.
9
+ The `vitest-agent-mcp` MCP server bin. Exposes action-keyed tools over stdio that give LLM agents structured access to test data, coverage, history, failure signatures, TDD lifecycle state and more. Also surfaces six framing-only prompts.
10
10
 
11
11
  ## Features
12
12
 
13
13
  - **29 action-keyed tools** — per-CRUD families collapse into single tools dispatching on an `action` discriminator; covers `test_status`, `test_overview`, `test_coverage`, `test_errors`, `run_tests`, `note`, `hypothesis`, `tdd_task`, `tdd_goal`, `tdd_behavior` and more
14
- - **Four MCP resources** — vendored Vitest documentation (`vitest://docs/`) and curated testing patterns (`vitest-agent://patterns/`) with per-page titles, descriptions and `audience`/`priority` annotations
15
14
  - **Six framing prompts** — `triage`, `why-flaky`, `regression-since-pass`, `explain-failure`, `tdd-resume`, `wrapup`
16
15
  - **Idempotency middleware** — `tdd_task`, `tdd_goal`, `tdd_behavior` and `hypothesis` create-actions are idempotent on derived keys
17
16
 
package/index.d.ts CHANGED
@@ -652,6 +652,7 @@ declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
652
652
  readonly classifications: {
653
653
  readonly [x: string]: string;
654
654
  };
655
+ readonly discoveryLastScannedAt?: string | null | undefined;
655
656
  } | {
656
657
  readonly kind: "timeout";
657
658
  readonly timeoutSeconds: number;
@@ -1529,10 +1530,10 @@ declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1529
1530
  //#endregion
1530
1531
  //#region src/server.d.ts
1531
1532
  /**
1532
- * Starts the MCP server over stdio, registering all tools, resources, and prompts.
1533
+ * Starts the MCP server over stdio, registering all tools and prompts.
1533
1534
  *
1534
1535
  * Constructs the MCP server instance, registers all tRPC-backed tools (wired through
1535
- * `ctx.runtime`), calls `registerAllResources` and `registerAllPrompts`, then connects
1536
+ * `ctx.runtime`), calls `registerAllPrompts`, then connects
1536
1537
  * a `StdioServerTransport`. Returns when the transport disconnects.
1537
1538
  *
1538
1539
  * @param ctx - the MCP context carrying the shared ManagedRuntime and session refs
package/index.js CHANGED
@@ -11,7 +11,7 @@ import { startMcpServer } from "./server.js";
11
11
  *
12
12
  * @public
13
13
  */
14
- const CURRENT_MCP_VERSION = "1.1.0";
14
+ const CURRENT_MCP_VERSION = "1.3.0";
15
15
 
16
16
  //#endregion
17
17
  export { CURRENT_MCP_VERSION, McpLive, appRouter, createCallerFactory, createCurrentSessionIdRef, createSessionContextRef, startMcpServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/mcp",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "Model Context Protocol server for vitest-agent. Exposes 53 tools for agent access to test data, TDD lifecycle, and session management.",
6
6
  "keywords": [
package/server.js CHANGED
@@ -30,7 +30,6 @@ import { TurnSearchAsMarkdown, TurnSearchResult } from "./tools/turn-search.js";
30
30
  import { WrapupPromptResult } from "./tools/wrapup-prompt.js";
31
31
  import { appRouter } from "./router.js";
32
32
  import { registerAllPrompts } from "./prompts/index.js";
33
- import { registerAllResources } from "./resources/index.js";
34
33
  import { effectToZodSchema } from "./utils/effect-to-zod.js";
35
34
  import { ChannelEvent, DataReader } from "@vitest-agent/sdk";
36
35
  import { Effect, Option, Schema } from "effect";
@@ -123,10 +122,10 @@ function structuredJsonResult(value) {
123
122
  return structuredResult(JSON.stringify(value, null, 2), value);
124
123
  }
125
124
  /**
126
- * Starts the MCP server over stdio, registering all tools, resources, and prompts.
125
+ * Starts the MCP server over stdio, registering all tools and prompts.
127
126
  *
128
127
  * Constructs the MCP server instance, registers all tRPC-backed tools (wired through
129
- * `ctx.runtime`), calls `registerAllResources` and `registerAllPrompts`, then connects
128
+ * `ctx.runtime`), calls `registerAllPrompts`, then connects
130
129
  * a `StdioServerTransport`. Returns when the transport disconnects.
131
130
  *
132
131
  * @param ctx - the MCP context carrying the shared ManagedRuntime and session refs
@@ -828,7 +827,6 @@ async function startMcpServer(ctx) {
828
827
  const data = await caller.ping();
829
828
  return structuredResult(data.message, data);
830
829
  });
831
- registerAllResources(server);
832
830
  registerAllPrompts(server);
833
831
  const transport = new StdioServerTransport();
834
832
  await server.connect(transport);
@@ -12,7 +12,8 @@ const RunTestsOk = Schema.Struct({
12
12
  classifications: Schema.Record({
13
13
  key: Schema.String,
14
14
  value: Schema.String
15
- }).annotations({ description: "Per-test classification labels: stable, new-failure, persistent, flaky, recovered." })
15
+ }).annotations({ description: "Per-test classification labels: stable, new-failure, persistent, flaky, recovered." }),
16
+ discoveryLastScannedAt: Schema.optional(Schema.NullOr(Schema.String)).annotations({ description: "ISO timestamp of the most recent real disk scan performed by discoverProjects() in this process (issue #100). `null`/absent means discovery has not scanned disk in this process yet (e.g. a config that doesn't call AgentPlugin.discover()). A stale-looking test count is self-explaining when compared against this value." })
16
17
  }).annotations({ identifier: "RunTestsOk" });
17
18
  const RunTestsTimeout = Schema.Struct({
18
19
  kind: Schema.Literal("timeout"),
@@ -69,6 +70,18 @@ function composeTagExpression(tags) {
69
70
  return parts.join(" and ");
70
71
  }
71
72
  const FORBIDDEN_CHARS = /[;|&`$(){}[\]<>!#]/;
73
+ const DISCOVERY_LAST_SCAN_SYMBOL = Symbol.for("vitest-agent:discovery:last-scan-at");
74
+ /**
75
+ * Reads the ISO timestamp of the most recent real disk scan performed by
76
+ * `discoverProjects()` in this process. `undefined` when discovery hasn't
77
+ * scanned disk in this process yet.
78
+ *
79
+ * @internal
80
+ */
81
+ function readDiscoveryLastScannedAt() {
82
+ const value = globalThis[DISCOVERY_LAST_SCAN_SYMBOL];
83
+ return typeof value === "string" ? value : void 0;
84
+ }
72
85
  const stdoutSinkStorage = new AsyncLocalStorage();
73
86
  const stderrSinkStorage = new AsyncLocalStorage();
74
87
  let _stdioPatched = false;
@@ -350,7 +363,8 @@ const runTests = publicProcedure.input(Schema.standardSchemaV1(Schema.Struct({
350
363
  kind: "ok",
351
364
  ...project !== void 0 && { project },
352
365
  report,
353
- classifications: classifications ? Object.fromEntries(classifications) : {}
366
+ classifications: classifications ? Object.fromEntries(classifications) : {},
367
+ discoveryLastScannedAt: readDiscoveryLastScannedAt() ?? null
354
368
  };
355
369
  } catch (err) {
356
370
  if (err instanceof Error && err.message === "VITEST_TIMEOUT") return {
@@ -368,4 +382,4 @@ const runTests = publicProcedure.input(Schema.standardSchemaV1(Schema.Struct({
368
382
  }));
369
383
 
370
384
  //#endregion
371
- export { RunTestsAsMarkdown, RunTestsResult, coerceErrors, composeTagExpression, formatNoMatchMarkdown, formatReportMarkdown, formatRunTestsMarkdown, runTests, sanitizeTestArgs, withStdioCaptured };
385
+ export { RunTestsAsMarkdown, RunTestsResult, coerceErrors, composeTagExpression, formatNoMatchMarkdown, formatReportMarkdown, formatRunTestsMarkdown, readDiscoveryLastScannedAt, runTests, sanitizeTestArgs, withStdioCaptured };
@@ -1,67 +0,0 @@
1
- {
2
- "patterns": [
3
- {
4
- "slug": "testing-effect-services-with-mock-layers",
5
- "title": "Testing Effect Services with Mock Layers",
6
- "summary": "Compose live and test layers, swap platform layers, assert on accumulated writes via state-container test layers.",
7
- "annotations": {
8
- "audience": ["assistant"],
9
- "priority": 0.9
10
- }
11
- },
12
- {
13
- "slug": "testing-effect-schema-definitions",
14
- "title": "Testing Effect Schema Definitions",
15
- "summary": "Round-trip Schema.Class and Schema.Struct, branded types, transformations, and decoding error assertions.",
16
- "annotations": {
17
- "audience": ["assistant"],
18
- "priority": 0.9
19
- }
20
- },
21
- {
22
- "slug": "authoring-a-custom-vitest-agent-reporter",
23
- "title": "Authoring a Custom vitest-agent Reporter",
24
- "summary": "Implement the VitestAgentReporterFactory contract: ReporterKit, RenderedOutput targets, stdOsc8 hyperlinks, composing with the default reporter.",
25
- "annotations": {
26
- "audience": ["assistant"],
27
- "priority": 0.7
28
- }
29
- },
30
- {
31
- "slug": "running-tests-via-mcp",
32
- "title": "Running Tests via the MCP run_tests Tool",
33
- "summary": "Scope runs with project/files/tags (there is no `filter` param), read the four-variant return shape, and understand why subset runs 'fail' coverage thresholds.",
34
- "annotations": {
35
- "audience": ["assistant"],
36
- "priority": 0.9
37
- }
38
- },
39
- {
40
- "slug": "silencing-leaking-output-in-tests",
41
- "title": "Silencing Leaking Log / Build Output in Tests",
42
- "summary": "Decision tree mapping each noise source (Effect logger, console.*, rsbuild, tsdown, API Extractor) to its silencing technique, with an assert-on-output guardrail.",
43
- "annotations": {
44
- "audience": ["assistant"],
45
- "priority": 0.8
46
- }
47
- },
48
- {
49
- "slug": "known-issues-and-caveats",
50
- "title": "Known Issues & Instrumentation Caveats",
51
- "summary": "Distinguishes real vitest-agent issues (DataStoreError UNIQUE race) from upstream Vitest caveats (coverage-dir ENOENT), already-fixed bugs (perf_hooks), and misconceptions (discovery-cache staleness).",
52
- "annotations": {
53
- "audience": ["assistant"],
54
- "priority": 0.7
55
- }
56
- },
57
- {
58
- "slug": "operating-vitest-agent-as-an-agent",
59
- "title": "Operating vitest-agent as an Agent",
60
- "summary": "Read first: the front-loaded facts an agent needs (no run_tests filter param, coverage-in-subset behavior, consoleLeaks signal in run_tests output, VITEST_AGENT_CONSOLE CLI escape hatch, attribution is auto-recovered) with links to the deeper patterns.",
61
- "annotations": {
62
- "audience": ["assistant"],
63
- "priority": 0.95
64
- }
65
- }
66
- ]
67
- }
@@ -1,82 +0,0 @@
1
- # Authoring a Custom vitest-agent Reporter
2
-
3
- ## When to use
4
-
5
- You want output behavior that the named factories in `@vitest-agent/reporter` (`defaultReporter`, `markdownReporter`, `jsonReporter`, etc.) do not provide. Examples: SARIF output for code-scanning ingestion, JUnit XML alongside the default markdown, a side-channel that posts to an internal API.
6
-
7
- ## The contract
8
-
9
- A reporter is a function that takes a `ReporterKit` and returns either a single `VitestAgentReporter` or an array. A reporter has exactly one method: synchronous `render(input)` that returns `RenderedOutput[]`. No I/O, no Vitest lifecycle. The plugin handles persistence, classification, baselines, and trends; reporters render the resulting data and the plugin routes the outputs to their declared targets.
10
-
11
- ```typescript
12
- type VitestAgentReporterFactory =
13
- (kit: ReporterKit) =>
14
- VitestAgentReporter | ReadonlyArray<VitestAgentReporter>;
15
-
16
- interface VitestAgentReporter {
17
- readonly render:
18
- (input: ReporterRenderInput) => ReadonlyArray<RenderedOutput>;
19
- }
20
- ```
21
-
22
- `ReporterKit` carries `config`, `stdEnv`, and `stdOsc8` (a pre-bound hyperlink helper). `ReporterRenderInput` carries `reports` (one per project), `classifications` (a Map keyed by `TestReport.fullName`), and an optional `trendSummary`.
23
-
24
- ## Minimal example: a SARIF sidecar
25
-
26
- ```typescript
27
- import type { VitestAgentReporterFactory } from "@vitest-agent/sdk";
28
-
29
- export const sarifReporter: VitestAgentReporterFactory = (kit) => ({
30
- render: (input) => {
31
- const sarif = buildSarif(input.reports);
32
- return [
33
- {
34
- target: "file",
35
- content: JSON.stringify(sarif),
36
- contentType: "application/sarif+json",
37
- },
38
- ];
39
- },
40
- });
41
- ```
42
-
43
- The `target: "file"` slot is reserved for arbitrary on-disk artifacts; the convention for resolving the path will land in a future minor (currently a no-op routing target). Until then, use `target: "stdout"` for output that should reach the user immediately.
44
-
45
- ## Composing with the default
46
-
47
- If you want your reporter to layer on top of the default rather than replace it, return an array:
48
-
49
- ```typescript
50
- import { defaultReporter, type VitestAgentReporterFactory } from "@vitest-agent/reporter";
51
-
52
- export const myReporter: VitestAgentReporterFactory = (kit) => {
53
- const inner = defaultReporter(kit);
54
- const innerArr = Array.isArray(inner) ? inner : [inner];
55
- return [...innerArr, sarifReporter(kit)];
56
- };
57
- ```
58
-
59
- ## Wiring into the plugin
60
-
61
- ```typescript
62
- // vitest.config.ts
63
- import { defineConfig } from "vitest/config";
64
- import { agentPlugin } from "@vitest-agent/plugin";
65
- import { myReporter } from "./my-reporter.js";
66
-
67
- export default defineConfig({
68
- plugins: [agentPlugin({ reporterFactory: myReporter })],
69
- });
70
- ```
71
-
72
- ## Anti-patterns
73
-
74
- - **Don't reach into Vitest's lifecycle from a reporter.** The plugin owns it. If you need a Vitest hook, you have outgrown this contract — fork the plugin instead.
75
- - **Don't return Promises from `render`.** The contract is sync. If you have async work, do it ahead of time and pass the resolved data into your factory closure.
76
- - **Don't use `stdOsc8` outside terminal targets.** OSC-8 escapes only render in capable terminals; `kit.stdOsc8` already gates this for you. Calling it from a `target: "github-summary"` reporter is harmless (it returns the bare label) but signals confused intent.
77
-
78
- ## See also
79
-
80
- - `vitest://docs/api/advanced/reporters` — Vitest's own reporter API (different surface; informative for context)
81
- - `packages/reporter/src/default.ts` — The composition pattern the default reporter uses
82
- - `packages/sdk/src/contracts/reporter.ts` — Full type definitions for the contract
@@ -1,52 +0,0 @@
1
- # Known Issues & Instrumentation Caveats
2
-
3
- ## When to use
4
-
5
- A test run surfaced an error or oddity that looks like a vitest-agent bug.
6
- Check it against this list first — several are upstream Vitest behavior, an
7
- already-shipped fix, or a misconception, not something to investigate as a
8
- consumer-side problem.
9
-
10
- ## `DataStoreError` on a UNIQUE collision — live, retry
11
-
12
- A concurrent agent registration (on `idempotency_key`) or two concurrent turn
13
- writes (on `(session_id, turn_no)`) can race the persistence layer's
14
- check-then-insert and surface a `DataStoreError` carrying
15
- `UNIQUE constraint failed`. It is not a consumer bug and not data corruption —
16
- retry the operation. The SELECT pre-check narrows but does not close the race.
17
-
18
- ## `coverage/.tmp … ENOENT coverage-0.json` — inherent Vitest, not a bug
19
-
20
- Running Vitest in two processes at once (for example a CLI run alongside the
21
- `vitest-vscode` extension) makes them share Vitest's default
22
- `coverage.reportsDirectory`, and one process can delete the temp dir the other
23
- is writing. vitest-agent never sets `reportsDirectory`, so this is an upstream
24
- multi-process Vitest caveat. Give each concurrent process its own
25
- `coverage.reportsDirectory` (or serialize them).
26
-
27
- ## `MaxPerformanceEntryBufferExceededWarning` — resolved, stop chasing it
28
-
29
- This `perf_hooks` warning on long runs was fixed in a shipped
30
- `@vitest-agent/reporter` release: React 19's development reconciler emits a
31
- `performance.measure()` per render, and the live renderer now drains Node's
32
- user-timing buffer after each render cycle. If you still see it, update
33
- `@vitest-agent/reporter`. Do not investigate it as a fault in your own repo.
34
-
35
- ## Stale test counts — re-run, there is no warm cache
36
-
37
- Moving or adding test files does not require an MCP restart. Discovery is
38
- re-walked fresh on every Vitest run; the MCP serves counts from the database,
39
- which only updates when tests are re-run. Stale numbers mean the tests have not
40
- been re-run — not that a discovery cache is warm. Restarting the MCP would not
41
- refresh them.
42
-
43
- ## A run that rebuilds `dist/` mid-run — expected
44
-
45
- A host project's Vitest `globalSetup` may call `AgentPlugin.runScript(...)`
46
- (for example `pnpm turbo run build:dev`), which can transiently tear down and
47
- rebuild `dist/` during the run. This is the host project's configuration, not a
48
- broken workspace.
49
-
50
- ## See also
51
-
52
- - `vitest-agent://patterns/running-tests-via-mcp` — why subset runs "fail" coverage thresholds
@@ -1,62 +0,0 @@
1
- # Operating vitest-agent as an Agent
2
-
3
- ## When to use
4
-
5
- Read this first when you are an agent driving a project that uses
6
- `@vitest-agent/*`. It front-loads the handful of facts that otherwise cost
7
- trial-and-error, then points you at the deeper patterns.
8
-
9
- ## The facts that save the most time
10
-
11
- 1. **Run tests with `run_tests`, not Bash `vitest`.** `run_tests` persists
12
- results, classifications, coverage, and history and fires the post-tool-use
13
- hooks. Shelling out to `vitest` bypasses all of that.
14
- 2. **`run_tests` has no `filter` parameter.** Scope with `project` (the Vitest
15
- project name), `files` (globs), or `tags`. An unknown key like `filter` is
16
- silently dropped, so the whole suite runs.
17
- 3. **Subset runs "fail" coverage thresholds by design.** A single-file run
18
- exiting with `ERROR: Coverage … does not meet global threshold` is expected
19
- — global thresholds applied to partial coverage. There is no per-run
20
- coverage toggle in `run_tests`; it inherits your `vitest.config`. For
21
- isolated inspection use the CLI: `vitest run <file> --coverage.enabled=false`.
22
- 4. **Stray `console.*` is surfaced by `run_tests` as a signal, not raw logs.**
23
- The `ok` result's `report.consoleLeaks` field lists writes by file with
24
- counts, optional per-test attribution, and a truncated sample. `run_tests`
25
- still null-routes Vitest's stdout; the signal captures what was printed
26
- without forwarding raw log lines into agent context. To see the raw output
27
- for a flagged file, run Vitest on the CLI:
28
- `VITEST_AGENT_CONSOLE=passthrough pnpm test`. Details at
29
- `vitest-agent://patterns/running-tests-via-mcp`.
30
- 5. **Session attribution is recovered for you.** The SessionStart hook writes
31
- the `VITEST_AGENT_*` identity into the environment and the SDK recovers it —
32
- you never set those vars by hand. The only behavioral knobs are
33
- `VITEST_REPORTER_LOG_LEVEL`, `VITEST_REPORTER_LOG_FILE`, and `NO_COLOR`.
34
- 6. **Stale counts mean tests were not re-run**, not a warm cache. Discovery
35
- re-walks per Vitest run; the MCP serves counts from the database.
36
- 7. **Some "leaks" are guardrail tests** that assert on their own output. Do not
37
- silence output a test captures and `expect`s on.
38
-
39
- ## Environment, briefly
40
-
41
- You do not configure vitest-agent through environment variables. The
42
- `VITEST_AGENT_*` vars (chat id, conversation id, agent ids, project dir,
43
- sidecar bin) are attribution plumbing written by the Claude Code plugin's
44
- SessionStart hook and recovered automatically. The vars you might set:
45
-
46
- - `VITEST_REPORTER_LOG_LEVEL` / `VITEST_REPORTER_LOG_FILE` — diagnostic
47
- logger (separate from the console reporter).
48
- - `NO_COLOR` — disables ANSI color in rendered output.
49
- - `VITEST_AGENT_CONSOLE=passthrough` — overrides the resolved console mode
50
- for the active executor on a CLI `vitest` run. Useful when investigating
51
- files flagged by `report.consoleLeaks`. Invalid-for-slot values warn to
52
- stderr and are ignored.
53
-
54
- ## Where to go next
55
-
56
- | You want to… | Read |
57
- | --- | --- |
58
- | Scope a run, read the return shape, understand coverage-in-subset | `vitest-agent://patterns/running-tests-via-mcp` |
59
- | Silence noisy log/build output in tests | `vitest-agent://patterns/silencing-leaking-output-in-tests` |
60
- | Tell tooling noise apart from real failures | `vitest-agent://patterns/known-issues-and-caveats` |
61
- | Read the full console-mode matrix (human prose) | <https://vitest-agent.dev/guide/console-modes> |
62
- | The human-facing version of this page | <https://vitest-agent.dev/guide/operating-as-an-agent> |
@@ -1,103 +0,0 @@
1
- # Running Tests via the MCP `run_tests` Tool
2
-
3
- ## When to use
4
-
5
- You want to execute the Vitest suite (or a subset) from an agent. Always prefer `run_tests` over shelling out to `vitest` — it persists results, classifications, coverage, and history to the project database and drives the post-tool-use hooks. Re-running `vitest` over Bash bypasses all of that.
6
-
7
- ## Scoping a run — there is no `filter` parameter
8
-
9
- `run_tests` accepts exactly these inputs:
10
-
11
- | Field | Type | Default | Scopes by |
12
- | --- | --- | --- | --- |
13
- | `files` | `string[]` | `[]` | Vitest file patterns: exact paths or globs |
14
- | `project` | `string` | unset | The Vitest **project name** from your config |
15
- | `tags` | `{ all?: string[]; any?: string[]; none?: string[] }` | unset | Vitest tag expression |
16
- | `passWithNoTests` | `boolean` | config value | Per-call override of `test.passWithNoTests` |
17
- | `timeout` | `number` (seconds) | `120` | Per-call run timeout |
18
-
19
- There is **no** `filter` field. Passing one (`run_tests({ filter: "@my/pkg" })`) is silently dropped — the call then runs with no filters, so the **entire** suite executes. To scope to one package, pass its Vitest project name as `project`; to scope to one file, pass it in `files`.
20
-
21
- `project` matches the project **name** defined in `vitest.config.ts`, not the npm package name. They often differ — check your config for the actual project name.
22
-
23
- `tags` sub-filters AND together (with each other and with `project`/`files`): `all` → `"a and b"`, `any` → `"(a or b)"`, `none` → `"not a and not b"`.
24
-
25
- ## Return shape
26
-
27
- `run_tests` returns one of four variants — discriminate on `kind`:
28
-
29
- | `kind` | Fields | Meaning |
30
- | --- | --- | --- |
31
- | `"ok"` | `report`, `classifications` (map of test full-name → `stable`/`new-failure`/`persistent`/`flaky`/`recovered`), optional `project` | The run completed |
32
- | `"no-match"` | `filter` (the resolved `project`/`files`/`tags`/`resolvedExpression`) | A filter was supplied but matched zero tests |
33
- | `"timeout"` | `timeoutSeconds` | Exceeded the timeout |
34
- | `"error"` | `message` | The run errored |
35
-
36
- A `no-match` is filter-driven: it fires when you supplied a filter and zero tests matched. Treat it as a finding (typo in `project`/`files`?) rather than a pass.
37
-
38
- ## Coverage on subset runs reads as a failure — by design
39
-
40
- A single-file or single-project run will commonly exit non-zero with:
41
-
42
- ```text
43
- ERROR: Coverage for lines (59.91%) does not meet global threshold (70%)
44
- ```
45
-
46
- This is expected: your global coverage thresholds are applied to a partial run, so partial coverage "fails" them. It is not a real test failure.
47
-
48
- `run_tests` has **no per-run coverage toggle** — it deliberately inherits your `vitest.config` `coverage.enabled` (forcing it off here used to override intentional "coverage on by default" setups). For clean isolated inspection, drop to the CLI:
49
-
50
- ```bash
51
- vitest run path/to/one.test.ts --coverage.enabled=false
52
- ```
53
-
54
- ## Stray console output — `report.consoleLeaks`
55
-
56
- When the run produces stray `console.*` output, the `report` object on an
57
- `"ok"` result carries an optional `consoleLeaks` field. It is omitted
58
- entirely when the run produced no user console output.
59
-
60
- Shape:
61
-
62
- - `total` — total stray console writes across the run
63
- - `byFile` — one entry per file that produced writes:
64
- - `file` — the test file path
65
- - `stdout` — writes to stdout-class streams (`log`, `info`, `debug`)
66
- - `stderr` — writes to stderr-class streams (`error`, `warn`)
67
- - `tests` (optional) — test names where writes were attributed
68
- - `sample` (optional) — truncated excerpt of the first write in this file
69
- - `truncated` (optional) — `true` when `byFile` was capped
70
-
71
- Use `byFile[].file` to locate which files to investigate and `sample` to
72
- find the call site, without dumping full log content into agent context.
73
- The markdown summary line also surfaces the leak count inline (e.g.
74
- `⚠ 3 stray console writes across 2 files (see consoleLeaks)`).
75
-
76
- ### Console-output visibility by surface
77
-
78
- | Surface | Sees stray `console.*` | Per-test attribution |
79
- | --- | --- | --- |
80
- | `run_tests` (MCP) | yes — `consoleLeaks` signal (counts + sample) | per file, per test where resolvable |
81
- | Human at a TTY | yes — Vitest's own `stdout \|` / `stderr \|` lines | yes (TTY only) |
82
- | Piped shell (default) | no — agent-shaped summary suppresses it | n/a |
83
- | Piped shell + `VITEST_AGENT_CONSOLE=passthrough` | yes — raw passthrough | no (raw, unlabeled) |
84
-
85
- ### `VITEST_AGENT_CONSOLE` — CLI escape hatch
86
-
87
- To see raw console output for a file that `consoleLeaks` flagged, run
88
- Vitest directly on the CLI with the override set:
89
-
90
- ```bash
91
- VITEST_AGENT_CONSOLE=passthrough pnpm test
92
- ```
93
-
94
- This overrides the plugin's resolved console mode to `passthrough` for
95
- the active executor — Vitest's own reporters emit console output
96
- unfiltered. An invalid value for the current executor slot warns to
97
- stderr and is ignored.
98
-
99
- ## See also
100
-
101
- - `vitest-agent://patterns/operating-vitest-agent-as-an-agent` — the orientation index
102
- - `vitest-agent://patterns/known-issues-and-caveats` — coverage-dir races and other instrumentation caveats
103
- - `vitest://docs/config/index` — Vitest's native config reference
@@ -1,91 +0,0 @@
1
- # Silencing Leaking Log / Build Output in Tests
2
-
3
- ## When to use
4
-
5
- A test run is polluted with stray log lines, build-tool banners, or framework
6
- diagnostics that drown the signal. The fix differs per source — identify the
7
- source first, then apply the matching technique.
8
-
9
- ## Guardrail: do not silence output a test asserts on
10
-
11
- Before silencing anything, confirm the test does not capture and `expect` on
12
- the output. Some tests deliberately spy on `process.stdout.write` /
13
- `process.stderr.write` (or `console.*`) and assert on `.mock.calls` to verify
14
- what a formatter emits. Silencing those breaks the assertion. If you see a
15
- `vi.spyOn(process.stdout, "write")` whose `.mock.calls` are asserted, that
16
- output is the test subject — leave it alone.
17
-
18
- ## Decision tree
19
-
20
- | Source (what the noise looks like) | Technique |
21
- | --- | --- |
22
- | Effect default logger (`timestamp=… level=INFO message=…`) | Provide a silent logger layer |
23
- | Plain `console.log` / `console.warn` / `console.error` | Spy + mock the method |
24
- | rsbuild (`info build started…`, file-size table) | Set `@rsbuild/core` logger level to silent |
25
- | tsdown / rolldown (`ℹ entry:`, `✔ Build complete`) | Pass `logLevel: "silent"` to the build |
26
- | API Extractor (`(ae-missing-release-tag)` to stderr) | Pass an `onMessage` handler that marks messages handled |
27
-
28
- ## Effect default logger
29
-
30
- Provide a silent logger at the run/layer boundary. This mirrors how the SDK's
31
- own `LoggerLive` builds its silent variant (`packages/sdk/src/layers/LoggerLive.ts`):
32
-
33
- ```typescript
34
- import { Effect, Logger } from "effect";
35
-
36
- const silent = Logger.replace(Logger.defaultLogger, Logger.none);
37
-
38
- await Effect.runPromise(program.pipe(Effect.provide(silent)));
39
- ```
40
-
41
- `Logger.minimumLogLevel(LogLevel.None)` is an equivalent gate.
42
-
43
- ## Plain `console.*`
44
-
45
- ```typescript
46
- import { beforeEach, vi } from "vitest";
47
-
48
- beforeEach(() => {
49
- vi.spyOn(console, "warn").mockImplementation(() => {});
50
- vi.spyOn(console, "error").mockImplementation(() => {});
51
- });
52
- ```
53
-
54
- ## rsbuild reporter
55
-
56
- rsbuild writes through its own `logger` singleton, **not** `console.*`, so
57
- console mocks miss it. Set the level and restore it:
58
-
59
- ```typescript
60
- import { logger } from "@rsbuild/core";
61
-
62
- const prev = logger.level;
63
- logger.level = "silent";
64
- try {
65
- await build();
66
- } finally {
67
- logger.level = prev;
68
- }
69
- ```
70
-
71
- ## tsdown / rolldown
72
-
73
- Pass `logLevel: "silent"` to the build call (or inject a no-op output writer).
74
-
75
- ## API Extractor
76
-
77
- Mark diagnostics handled so they are not printed — this is the production quiet
78
- path:
79
-
80
- ```typescript
81
- extractorResult = Extractor.invoke(config, {
82
- messageCallback: (message) => {
83
- message.handled = true;
84
- },
85
- });
86
- ```
87
-
88
- ## See also
89
-
90
- - `vitest-agent://patterns/known-issues-and-caveats` — distinguishing tooling noise from real failures
91
- - `vitest://docs/api/vi` — the `vi.spyOn` / mock API
@@ -1,71 +0,0 @@
1
- # Testing Effect Schema Definitions
2
-
3
- ## When to use
4
-
5
- When you have an Effect Schema (`Schema.Struct`, `Schema.Class`, branded type, transformation) that defines a public-API shape and you want to verify: round-trip encode/decode preserves data, decoding rejects invalid input with useful errors, transformations behave correctly.
6
-
7
- ## Three test patterns
8
-
9
- ### Pattern A: round-trip
10
-
11
- ```typescript
12
- import { Schema } from "effect";
13
- import { describe, expect, it } from "vitest";
14
-
15
- const User = Schema.Struct({
16
- id: Schema.Number,
17
- name: Schema.String,
18
- });
19
-
20
- it("round-trips through encode + decode", () => {
21
- const value = { id: 42, name: "Ada" };
22
- const encoded = Schema.encodeUnknownSync(User)(value);
23
- const decoded = Schema.decodeUnknownSync(User)(encoded);
24
- expect(decoded).toEqual(value);
25
- });
26
- ```
27
-
28
- ### Pattern B: decoding error assertions
29
-
30
- ```typescript
31
- import { Either, Schema } from "effect";
32
- import { describe, expect, it } from "vitest";
33
-
34
- it("rejects invalid input with the expected error path", () => {
35
- const result = Schema.decodeUnknownEither(User)({ id: "not-a-number", name: "Ada" });
36
- expect(Either.isLeft(result)).toBe(true);
37
- if (Either.isLeft(result)) {
38
- const formatted = String(result.left);
39
- expect(formatted).toContain("id");
40
- expect(formatted).toMatch(/expected number/i);
41
- }
42
- });
43
- ```
44
-
45
- ### Pattern C: transformations
46
-
47
- For `Schema.transform` between two shapes (typical for parsing JSON-stringified payloads):
48
-
49
- ```typescript
50
- const Comma = Schema.transform(Schema.String, Schema.Array(Schema.String), {
51
- decode: (s) => s.split(","),
52
- encode: (a) => a.join(","),
53
- });
54
-
55
- it("decodes and encodes the inverse", () => {
56
- expect(Schema.decodeUnknownSync(Comma)("a,b,c")).toEqual(["a", "b", "c"]);
57
- expect(Schema.encodeUnknownSync(Comma)(["a", "b"])).toBe("a,b");
58
- });
59
- ```
60
-
61
- ## Anti-patterns
62
-
63
- - **Don't assert on stringified errors verbatim.** Effect Schema's error formatting can shift between minor versions; assert on substrings or use `ParseResult.TreeFormatter` for stable output.
64
- - **Don't write tests that rely on `Schema.transformOrFail` failing _silently_.** When a transform can fail, exercise the failure path explicitly — `Either` results from `decodeUnknownEither` are the right tool.
65
- - **Don't recreate the schema in the test.** Import the production definition; otherwise the test passes when the production schema drifts.
66
-
67
- ## See also
68
-
69
- - `vitest://docs/api/expect` — Vitest matcher reference for the assertion patterns
70
- - `vitest-agent://patterns/testing-effect-services-with-mock-layers` — Companion pattern; services hand around Schema-typed data
71
- - Effect Schema docs at `https://effect.website/docs/schema/introduction`