@vitest-agent/mcp 1.0.0 → 1.1.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 (223) hide show
  1. package/bin/vitest-agent-mcp.js +1 -17
  2. package/index.d.ts +322 -313
  3. package/index.js +2 -4
  4. package/middleware/idempotency.js +1 -1
  5. package/package.json +2 -2
  6. package/patterns/_meta.json +67 -0
  7. package/patterns/authoring-a-custom-vitest-agent-reporter.md +82 -0
  8. package/patterns/known-issues-and-caveats.md +52 -0
  9. package/patterns/operating-vitest-agent-as-an-agent.md +62 -0
  10. package/patterns/running-tests-via-mcp.md +103 -0
  11. package/patterns/silencing-leaking-output-in-tests.md +91 -0
  12. package/patterns/testing-effect-schema-definitions.md +71 -0
  13. package/patterns/testing-effect-services-with-mock-layers.md +63 -0
  14. package/resources/index.js +16 -5
  15. package/resources/manifest-schema.js +1 -1
  16. package/tools/acceptance-metrics.js +1 -1
  17. package/tools/cache-health.js +1 -1
  18. package/tools/commit-changes.js +1 -1
  19. package/tools/configure.js +1 -1
  20. package/tools/coverage.js +1 -1
  21. package/tools/errors.js +1 -1
  22. package/tools/failure-signature-get.js +1 -1
  23. package/tools/file-coverage.js +1 -1
  24. package/tools/history.js +1 -1
  25. package/tools/inventory.js +1 -1
  26. package/tools/overview.js +1 -1
  27. package/tools/run-tests.js +15 -3
  28. package/tools/settings-list.js +1 -1
  29. package/tools/status.js +1 -1
  30. package/tools/tdd-artifact.js +1 -1
  31. package/tools/tdd-task.js +1 -1
  32. package/tools/test.js +1 -1
  33. package/tools/trends.js +1 -1
  34. package/tools/turn-search.js +1 -1
  35. package/vendor/vitest-docs/ATTRIBUTION.md +5 -0
  36. package/vendor/vitest-docs/api/advanced/artifacts.md +189 -0
  37. package/vendor/vitest-docs/api/advanced/metadata.md +68 -0
  38. package/vendor/vitest-docs/api/advanced/plugin.md +168 -0
  39. package/vendor/vitest-docs/api/advanced/reporters.md +342 -0
  40. package/vendor/vitest-docs/api/advanced/runner.md +334 -0
  41. package/vendor/vitest-docs/api/advanced/test-case.md +302 -0
  42. package/vendor/vitest-docs/api/advanced/test-collection.md +89 -0
  43. package/vendor/vitest-docs/api/advanced/test-module.md +140 -0
  44. package/vendor/vitest-docs/api/advanced/test-project.md +321 -0
  45. package/vendor/vitest-docs/api/advanced/test-specification.md +96 -0
  46. package/vendor/vitest-docs/api/advanced/test-suite.md +230 -0
  47. package/vendor/vitest-docs/api/advanced/vitest.md +684 -0
  48. package/vendor/vitest-docs/api/assert-type.md +22 -0
  49. package/vendor/vitest-docs/api/assert.md +1960 -0
  50. package/vendor/vitest-docs/api/browser/assertions.md +1277 -0
  51. package/vendor/vitest-docs/api/browser/commands.md +154 -0
  52. package/vendor/vitest-docs/api/browser/context.md +338 -0
  53. package/vendor/vitest-docs/api/browser/interactivity.md +681 -0
  54. package/vendor/vitest-docs/api/browser/locators.md +1171 -0
  55. package/vendor/vitest-docs/api/browser/react.md +346 -0
  56. package/vendor/vitest-docs/api/browser/svelte.md +292 -0
  57. package/vendor/vitest-docs/api/browser/vue.md +222 -0
  58. package/vendor/vitest-docs/api/describe.md +374 -0
  59. package/vendor/vitest-docs/api/expect-typeof.md +571 -0
  60. package/vendor/vitest-docs/api/expect.md +2304 -0
  61. package/vendor/vitest-docs/api/hooks.md +463 -0
  62. package/vendor/vitest-docs/api/mock.md +701 -0
  63. package/vendor/vitest-docs/api/test.md +926 -0
  64. package/vendor/vitest-docs/api/vi.md +1372 -0
  65. package/vendor/vitest-docs/config/alias.md +13 -0
  66. package/vendor/vitest-docs/config/allowonly.md +32 -0
  67. package/vendor/vitest-docs/config/api.md +27 -0
  68. package/vendor/vitest-docs/config/attachmentsdir.md +6 -0
  69. package/vendor/vitest-docs/config/bail.md +9 -0
  70. package/vendor/vitest-docs/config/benchmark.md +65 -0
  71. package/vendor/vitest-docs/config/browser/api.md +23 -0
  72. package/vendor/vitest-docs/config/browser/commands.md +6 -0
  73. package/vendor/vitest-docs/config/browser/connecttimeout.md +10 -0
  74. package/vendor/vitest-docs/config/browser/detailspanelposition.md +38 -0
  75. package/vendor/vitest-docs/config/browser/enabled.md +40 -0
  76. package/vendor/vitest-docs/config/browser/expect.md +250 -0
  77. package/vendor/vitest-docs/config/browser/headless.md +7 -0
  78. package/vendor/vitest-docs/config/browser/instances.md +47 -0
  79. package/vendor/vitest-docs/config/browser/isolate.md +11 -0
  80. package/vendor/vitest-docs/config/browser/locators.md +24 -0
  81. package/vendor/vitest-docs/config/browser/orchestratorscripts.md +39 -0
  82. package/vendor/vitest-docs/config/browser/playwright.md +214 -0
  83. package/vendor/vitest-docs/config/browser/preview.md +32 -0
  84. package/vendor/vitest-docs/config/browser/provider.md +79 -0
  85. package/vendor/vitest-docs/config/browser/screenshotdirectory.md +6 -0
  86. package/vendor/vitest-docs/config/browser/screenshotfailures.md +6 -0
  87. package/vendor/vitest-docs/config/browser/testerhtmlpath.md +5 -0
  88. package/vendor/vitest-docs/config/browser/trace.md +43 -0
  89. package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +10 -0
  90. package/vendor/vitest-docs/config/browser/ui.md +7 -0
  91. package/vendor/vitest-docs/config/browser/viewport.md +6 -0
  92. package/vendor/vitest-docs/config/browser/webdriverio.md +64 -0
  93. package/vendor/vitest-docs/config/cache.md +26 -0
  94. package/vendor/vitest-docs/config/chaiconfig.md +29 -0
  95. package/vendor/vitest-docs/config/clearmocks.md +22 -0
  96. package/vendor/vitest-docs/config/coverage.md +455 -0
  97. package/vendor/vitest-docs/config/css.md +47 -0
  98. package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +23 -0
  99. package/vendor/vitest-docs/config/deps.md +127 -0
  100. package/vendor/vitest-docs/config/detectasyncleaks.md +39 -0
  101. package/vendor/vitest-docs/config/diff.md +96 -0
  102. package/vendor/vitest-docs/config/dir.md +7 -0
  103. package/vendor/vitest-docs/config/disableconsoleintercept.md +15 -0
  104. package/vendor/vitest-docs/config/env.md +5 -0
  105. package/vendor/vitest-docs/config/environment.md +96 -0
  106. package/vendor/vitest-docs/config/environmentoptions.md +30 -0
  107. package/vendor/vitest-docs/config/exclude.md +49 -0
  108. package/vendor/vitest-docs/config/execargv.md +10 -0
  109. package/vendor/vitest-docs/config/expandsnapshotdiff.md +7 -0
  110. package/vendor/vitest-docs/config/expect.md +38 -0
  111. package/vendor/vitest-docs/config/experimental.md +510 -0
  112. package/vendor/vitest-docs/config/faketimers.md +51 -0
  113. package/vendor/vitest-docs/config/fileparallelism.md +11 -0
  114. package/vendor/vitest-docs/config/forcereruntriggers.md +19 -0
  115. package/vendor/vitest-docs/config/globals.md +42 -0
  116. package/vendor/vitest-docs/config/globalsetup.md +72 -0
  117. package/vendor/vitest-docs/config/hideskippedtests.md +7 -0
  118. package/vendor/vitest-docs/config/hooktimeout.md +7 -0
  119. package/vendor/vitest-docs/config/include-source.md +115 -0
  120. package/vendor/vitest-docs/config/include.md +71 -0
  121. package/vendor/vitest-docs/config/includetasklocation.md +17 -0
  122. package/vendor/vitest-docs/config/index.md +85 -0
  123. package/vendor/vitest-docs/config/isolate.md +13 -0
  124. package/vendor/vitest-docs/config/logheapusage.md +7 -0
  125. package/vendor/vitest-docs/config/maxconcurrency.md +9 -0
  126. package/vendor/vitest-docs/config/maxworkers.md +49 -0
  127. package/vendor/vitest-docs/config/mockreset.md +22 -0
  128. package/vendor/vitest-docs/config/mode.md +7 -0
  129. package/vendor/vitest-docs/config/name.md +111 -0
  130. package/vendor/vitest-docs/config/onconsolelog.md +25 -0
  131. package/vendor/vitest-docs/config/onstacktrace.md +32 -0
  132. package/vendor/vitest-docs/config/onunhandlederror.md +35 -0
  133. package/vendor/vitest-docs/config/open.md +7 -0
  134. package/vendor/vitest-docs/config/outputfile.md +7 -0
  135. package/vendor/vitest-docs/config/passwithnotests.md +7 -0
  136. package/vendor/vitest-docs/config/pool.md +45 -0
  137. package/vendor/vitest-docs/config/printconsoletrace.md +6 -0
  138. package/vendor/vitest-docs/config/projects.md +6 -0
  139. package/vendor/vitest-docs/config/provide.md +45 -0
  140. package/vendor/vitest-docs/config/reporters.md +69 -0
  141. package/vendor/vitest-docs/config/resolvesnapshotpath.md +36 -0
  142. package/vendor/vitest-docs/config/restoremocks.md +22 -0
  143. package/vendor/vitest-docs/config/retry.md +140 -0
  144. package/vendor/vitest-docs/config/root.md +6 -0
  145. package/vendor/vitest-docs/config/runner.md +6 -0
  146. package/vendor/vitest-docs/config/sequence.md +158 -0
  147. package/vendor/vitest-docs/config/server.md +68 -0
  148. package/vendor/vitest-docs/config/setupfiles.md +40 -0
  149. package/vendor/vitest-docs/config/silent.md +9 -0
  150. package/vendor/vitest-docs/config/slowtestthreshold.md +7 -0
  151. package/vendor/vitest-docs/config/snapshotenvironment.md +27 -0
  152. package/vendor/vitest-docs/config/snapshotformat.md +28 -0
  153. package/vendor/vitest-docs/config/snapshotserializers.md +6 -0
  154. package/vendor/vitest-docs/config/stricttags.md +30 -0
  155. package/vendor/vitest-docs/config/tags.md +141 -0
  156. package/vendor/vitest-docs/config/teardowntimeout.md +7 -0
  157. package/vendor/vitest-docs/config/testnamepattern.md +21 -0
  158. package/vendor/vitest-docs/config/testtimeout.md +7 -0
  159. package/vendor/vitest-docs/config/typecheck.md +77 -0
  160. package/vendor/vitest-docs/config/ui.md +15 -0
  161. package/vendor/vitest-docs/config/unstubenvs.md +20 -0
  162. package/vendor/vitest-docs/config/unstubglobals.md +20 -0
  163. package/vendor/vitest-docs/config/update.md +16 -0
  164. package/vendor/vitest-docs/config/vmmemorylimit.md +30 -0
  165. package/vendor/vitest-docs/config/watch.md +11 -0
  166. package/vendor/vitest-docs/config/watchtriggerpatterns.md +29 -0
  167. package/vendor/vitest-docs/guide/advanced/index.md +147 -0
  168. package/vendor/vitest-docs/guide/advanced/pool.md +148 -0
  169. package/vendor/vitest-docs/guide/advanced/reporters.md +93 -0
  170. package/vendor/vitest-docs/guide/advanced/tests.md +125 -0
  171. package/vendor/vitest-docs/guide/browser/aria-snapshots.md +470 -0
  172. package/vendor/vitest-docs/guide/browser/component-testing.md +571 -0
  173. package/vendor/vitest-docs/guide/browser/index.md +630 -0
  174. package/vendor/vitest-docs/guide/browser/multiple-setups.md +121 -0
  175. package/vendor/vitest-docs/guide/browser/trace-view.md +126 -0
  176. package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +734 -0
  177. package/vendor/vitest-docs/guide/cli-generated.md +972 -0
  178. package/vendor/vitest-docs/guide/cli.md +234 -0
  179. package/vendor/vitest-docs/guide/common-errors.md +163 -0
  180. package/vendor/vitest-docs/guide/coverage.md +515 -0
  181. package/vendor/vitest-docs/guide/debugging.md +127 -0
  182. package/vendor/vitest-docs/guide/environment.md +101 -0
  183. package/vendor/vitest-docs/guide/extending-matchers.md +160 -0
  184. package/vendor/vitest-docs/guide/features.md +310 -0
  185. package/vendor/vitest-docs/guide/filtering.md +175 -0
  186. package/vendor/vitest-docs/guide/ide.md +43 -0
  187. package/vendor/vitest-docs/guide/improving-performance.md +245 -0
  188. package/vendor/vitest-docs/guide/in-source.md +159 -0
  189. package/vendor/vitest-docs/guide/index.md +128 -0
  190. package/vendor/vitest-docs/guide/learn/async.md +147 -0
  191. package/vendor/vitest-docs/guide/learn/debugging-tests.md +210 -0
  192. package/vendor/vitest-docs/guide/learn/matchers.md +277 -0
  193. package/vendor/vitest-docs/guide/learn/mock-functions.md +277 -0
  194. package/vendor/vitest-docs/guide/learn/setup-teardown.md +240 -0
  195. package/vendor/vitest-docs/guide/learn/snapshots.md +166 -0
  196. package/vendor/vitest-docs/guide/learn/testing-in-practice.md +430 -0
  197. package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +127 -0
  198. package/vendor/vitest-docs/guide/learn/writing-tests.md +231 -0
  199. package/vendor/vitest-docs/guide/lifecycle.md +379 -0
  200. package/vendor/vitest-docs/guide/migration.md +863 -0
  201. package/vendor/vitest-docs/guide/mocking/classes.md +158 -0
  202. package/vendor/vitest-docs/guide/mocking/dates.md +52 -0
  203. package/vendor/vitest-docs/guide/mocking/file-system.md +74 -0
  204. package/vendor/vitest-docs/guide/mocking/functions.md +61 -0
  205. package/vendor/vitest-docs/guide/mocking/globals.md +20 -0
  206. package/vendor/vitest-docs/guide/mocking/modules.md +414 -0
  207. package/vendor/vitest-docs/guide/mocking/requests.md +114 -0
  208. package/vendor/vitest-docs/guide/mocking/timers.md +48 -0
  209. package/vendor/vitest-docs/guide/mocking.md +239 -0
  210. package/vendor/vitest-docs/guide/open-telemetry.md +156 -0
  211. package/vendor/vitest-docs/guide/parallelism.md +82 -0
  212. package/vendor/vitest-docs/guide/profiling-test-performance.md +243 -0
  213. package/vendor/vitest-docs/guide/projects.md +291 -0
  214. package/vendor/vitest-docs/guide/recipes.md +59 -0
  215. package/vendor/vitest-docs/guide/reporters.md +723 -0
  216. package/vendor/vitest-docs/guide/snapshot.md +620 -0
  217. package/vendor/vitest-docs/guide/test-annotations.md +103 -0
  218. package/vendor/vitest-docs/guide/test-context.md +902 -0
  219. package/vendor/vitest-docs/guide/test-tags.md +314 -0
  220. package/vendor/vitest-docs/guide/testing-types.md +149 -0
  221. package/vendor/vitest-docs/guide/ui.md +160 -0
  222. package/vendor/vitest-docs/guide/using-plugins.md +5 -0
  223. package/vendor/vitest-docs/manifest.json +1691 -0
@@ -0,0 +1,103 @@
1
+ # Test Annotations
2
+
3
+ Vitest supports annotating your tests with custom messages and files via the [`context.annotate`](/guide/test-context#annotate) API. These annotations will be attached to the test case and passed down to reporters in the [`onTestAnnotate`](/api/advanced/reporters#ontestannotate) hook.
4
+
5
+ ```ts
6
+ test('hello world', async ({ annotate }) => {
7
+ await annotate('this is my test')
8
+
9
+ if (condition) {
10
+ await annotate('this should\'ve errored', 'error')
11
+ }
12
+
13
+ const file = createTestSpecificFile()
14
+ await annotate('creates a file', { body: file })
15
+
16
+ await annotate('creates a file with text', {
17
+ contentType: 'text/markdown',
18
+ body: 'Hello **markdown**',
19
+ bodyEncoding: 'utf-8',
20
+ })
21
+ })
22
+ ```
23
+
24
+ ::: warning
25
+ The `annotate` function returns a Promise, so it needs to be awaited if you rely on it somehow. However, Vitest will also automatically await any non-awaited annotation before the test finishes.
26
+ :::
27
+
28
+ Depending on your reporter, you will see these annotations differently.
29
+
30
+ ## Built-in Reporters
31
+ ### default
32
+
33
+ The `default` reporter prints annotations only if the test has failed:
34
+
35
+ ```
36
+ ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
37
+
38
+ FAIL example.test.js > an example of a test with annotation
39
+ Error: thrown error
40
+ ❯ example.test.js:11:21
41
+ 9 | await annotate('annotation 1')
42
+ 10| await annotate('annotation 2', 'warning')
43
+ 11| throw new Error('thrown error')
44
+ | ^
45
+ 12| })
46
+
47
+ ❯ example.test.js:9:15 notice
48
+ ↳ annotation 1
49
+ ❯ example.test.js:10:15 warning
50
+ ↳ annotation 2
51
+
52
+ ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
53
+ ```
54
+
55
+ ### verbose
56
+
57
+ The `verbose` reporter is the only terminal reporter that reports annotations when the test doesn't fail.
58
+
59
+ ```
60
+ ✓ example.test.js > an example of a test with annotation
61
+
62
+ ❯ example.test.js:9:15 notice
63
+ ↳ annotation 1
64
+ ❯ example.test.js:10:15 warning
65
+ ↳ annotation 2
66
+
67
+ ```
68
+
69
+ ### html
70
+
71
+ The HTML reporter shows annotations the same way the UI does. You can see the annotation on the line where it was called. At the moment, if the annotation wasn't called in a test file, you cannot see it in the UI. We are planning to support a separate test summary view where it will be visible.
72
+
73
+ <img alt="Vitest UI" img-light src="/annotations-html-light.png">
74
+ <img alt="Vitest UI" img-dark src="/annotations-html-dark.png">
75
+
76
+ ### junit
77
+
78
+ The `junit` reporter lists annotations inside the testcase's `properties` tag. The JUnit reporter will ignore all attachments and will print only the type and the message.
79
+
80
+ ```xml
81
+ <testcase classname="basic/example.test.js" name="an example of a test with annotation" time="0.14315">
82
+ <properties>
83
+ <property name="notice" value="the message of the annotation">
84
+ </property>
85
+ </properties>
86
+ </testcase>
87
+ ```
88
+
89
+ ### github-actions
90
+
91
+ The `github-actions` reporter will print the annotation as a [notice message](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-notice-message) by default. You can configure the `type` by passing down the second argument as `notice`, `warning` or `error`. If type is none of these, Vitest will show the message as a notice.
92
+
93
+ <img alt="GitHub Actions" img-light src="/annotations-gha-light.png">
94
+ <img alt="GitHub Actions" img-dark src="/annotations-gha-dark.png">
95
+
96
+ ### tap
97
+
98
+ The `tap` and `tap-flat` reporters print annotations as diagnostic messages on a new line starting with a `#` symbol. They will ignore all attachments and will print only the type and message:
99
+
100
+ ```
101
+ ok 1 - an example of a test with annotation # time=143.15ms
102
+ # notice: the message of the annotation
103
+ ```