Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vitest-dev/vitest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.8
Choose a base ref
...
head repository: vitest-dev/vitest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.9
Choose a head ref

Commits on Mar 6, 2025

  1. docs: update shiki transformers and clarify root project (#7518)

    sheremet-va authored Mar 6, 2025
    Copy the full SHA
    419315b View commit details

Commits on Mar 7, 2025

  1. fix: typings of ctx.skip() as never (#7608)

    sirlancelot authored Mar 7, 2025
    Copy the full SHA
    09f3530 View commit details
  2. docs: fix shiki twoslash build error (#7620)

    hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    4f7db68 View commit details
  3. fix: cleanup vitest in public resolveConfig API (#7623)

    hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    db14ab7 View commit details
  4. test: ignore broken unhandled rejection error stack test (#7622)

    hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    6ece0d9 View commit details
  5. fix: fix toHaveBeenCalledWith(asymmetricMatcher) with undefined a…

    …rguments (#7624)
    hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    0fb21fa View commit details
  6. fix(vite-node): fix source map of inlined node_modules (#7557)

    hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    34aa322 View commit details
  7. fix: race condition in RPC filesystem cache. (#7531)

    dts authored Mar 7, 2025
    Copy the full SHA
    b7f5526 View commit details
  8. fix(browser): fail playwright timeouts earlier than a test timeout (#…

    …7565)
    
    Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
    sheremet-va and hi-ogawa authored Mar 7, 2025
    Copy the full SHA
    5eb4cd1 View commit details
  9. chore: use unplugin-isolated-decl with oxc-transform for dts build (

    #7609)
    
    Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
    hi-ogawa and sxzz authored Mar 7, 2025
    Copy the full SHA
    c0cf65f View commit details
  10. chore: use pnpm catalog (#7590)

    btea authored Mar 7, 2025
    Copy the full SHA
    7155aef View commit details
  11. Revert "fix(browser): remove @testing-library/dom from dependencies #…

    sheremet-va authored Mar 7, 2025
    Copy the full SHA
    94b27af View commit details

Commits on Mar 11, 2025

  1. fix(web-worker): ensure removeEventListener is bound to worker (#7631)

    joelgallant authored Mar 11, 2025
    Copy the full SHA
    ff42bcb View commit details
  2. fix(runner): show stacktrace on hook timeout error (#7502)

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    268a19e View commit details
  3. chore: remove renovate special rules for playwright, test and examples (

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    eab5c37 View commit details
  4. test(vite-node): test css import (#7653)

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    20b39c4 View commit details
  5. test: test hook cleanup timeout correctly (#7651)

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    e4b34b8 View commit details
  6. fix: fix getState().testPath during collection with no isolation (#…

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    3fb3fbf View commit details
  7. fix: support custom toString method in %s format (#7637)

    pengooseDev authored Mar 11, 2025
    Copy the full SHA
    46d93a2 View commit details
  8. refactor(ws-client): remove utils re-export (#7635)

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    df1fc8e View commit details
  9. refactor: coverage types to avoid mixing node and runtime types (#7627)

    sheremet-va authored Mar 11, 2025
    Copy the full SHA
    fcf3cf5 View commit details
  10. docs: add mockClear/mockReset/mockRestore examples (#7633)

    hi-ogawa authored Mar 11, 2025
    Copy the full SHA
    2d4537f View commit details
  11. chore(deps): update dependency @antfu/eslint-config to v4 (#7407)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
    renovate[bot] and sheremet-va authored Mar 11, 2025
    Copy the full SHA
    4b0451d View commit details
  12. chore(deps): update dependency eslint to ^9.22.0 (#7641)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 11, 2025
    Copy the full SHA
    470cbec View commit details

Commits on Mar 14, 2025

  1. fix(vite-node): fix missing buildStart (#7652)

    hi-ogawa authored Mar 14, 2025
    Copy the full SHA
    29f5a84 View commit details
  2. chore: fix various typos (#7663)

    aryaemami59 authored Mar 14, 2025
    Copy the full SHA
    3fdee3d View commit details

Commits on Mar 17, 2025

  1. ci: pin third party actions to commit shas (#7687)

    AriPerkkio authored Mar 17, 2025
    Copy the full SHA
    10bbbe9 View commit details
  2. fix(coverage): browser mode + coverage.all (#7597)

    AriPerkkio authored Mar 17, 2025
    Copy the full SHA
    422ba66 View commit details
  3. chore: release v3.0.9

    sheremet-va committed Mar 17, 2025
    Copy the full SHA
    8ea9e14 View commit details
Showing with 4,075 additions and 4,470 deletions.
  1. +1 −1 .github/actions/setup-and-cache/action.yml
  2. +3 −14 .github/renovate.json5
  3. +3 −3 .github/workflows/ci.yml
  4. +1 −1 .github/workflows/cr.yml
  5. +1 −1 .github/workflows/ecosystem-ci-trigger.yml
  6. +1 −1 .github/workflows/issue-close-require.yml
  7. +1 −1 .github/workflows/issue-labeled.yml
  8. +1 −1 .github/workflows/lock-closed-issues.yml
  9. +1 −1 .github/workflows/publish.yml
  10. +1 −0 docs/.vitepress/config.ts
  11. +2 −2 docs/advanced/api/reporters.md
  12. +1 −1 docs/advanced/api/test-project.md
  13. +1 −1 docs/advanced/api/test-specification.md
  14. +6 −6 docs/advanced/api/vitest.md
  15. +2 −2 docs/advanced/guide/tests.md
  16. +49 −2 docs/api/mock.md
  17. +2 −1 docs/guide/browser/interactivity-api.md
  18. +3 −3 docs/guide/browser/locators.md
  19. +2 −2 docs/guide/browser/multiple-setups.md
  20. +1 −1 docs/guide/browser/playwright.md
  21. +2 −2 docs/guide/improving-performance.md
  22. +2 −1 docs/guide/migration.md
  23. +12 −12 docs/package.json
  24. +1 −0 eslint.config.js
  25. +5 −3 package.json
  26. +6 −4 packages/browser/context.d.ts
  27. +2 −1 packages/browser/matchers.d.ts
  28. +11 −10 packages/browser/package.json
  29. +2 −0 packages/browser/providers/playwright.d.ts
  30. +21 −16 packages/browser/rollup.config.js
  31. +2 −1 packages/browser/src/client/client.ts
  32. +2 −2 packages/browser/src/client/orchestrator.ts
  33. +53 −182 packages/browser/src/client/tester/context.ts
  34. +2 −1 packages/browser/src/client/tester/expect-element.ts
  35. +18 −10 packages/browser/src/client/tester/locators/index.ts
  36. +103 −0 packages/browser/src/client/tester/locators/playwright.ts
  37. +1 −1 packages/browser/src/client/tester/locators/preview.ts
  38. +98 −4 packages/browser/src/client/tester/locators/webdriverio.ts
  39. +4 −2 packages/browser/src/client/tester/public-utils.ts
  40. +2 −1 packages/browser/src/client/tester/snapshot.ts
  41. +2 −1 packages/browser/src/client/tester/tester.ts
  42. +180 −0 packages/browser/src/client/tester/utils.ts
  43. +5 −117 packages/browser/src/client/utils.ts
  44. +1 −1 packages/browser/src/node/commands/click.ts
  45. +1 −1 packages/browser/src/node/commands/fill.ts
  46. +1 −1 packages/browser/src/node/commands/keyboard.ts
  47. +1 −1 packages/browser/src/node/commands/type.ts
  48. +3 −1 packages/browser/src/node/plugin.ts
  49. +2 −1 packages/browser/src/node/projectParent.ts
  50. +16 −16 packages/coverage-istanbul/package.json
  51. +6 −3 packages/coverage-istanbul/rollup.config.js
  52. +4 −2 packages/coverage-istanbul/src/provider.ts
  53. +19 −19 packages/coverage-v8/package.json
  54. +6 −3 packages/coverage-v8/rollup.config.js
  55. +2 −1 packages/coverage-v8/src/index.ts
  56. +38 −38 packages/coverage-v8/src/provider.ts
  57. +3 −3 packages/expect/package.json
  58. +6 −3 packages/expect/rollup.config.js
  59. +3 −1 packages/expect/src/jest-asymmetric-matchers.ts
  60. +13 −8 packages/expect/src/jest-expect.ts
  61. +6 −6 packages/mocker/package.json
  62. +7 −3 packages/mocker/rollup.config.js
  63. +3 −7 packages/mocker/src/node/automockPlugin.ts
  64. +5 −3 packages/mocker/src/node/mockerPlugin.ts
  65. +2 −2 packages/pretty-format/package.json
  66. +6 −3 packages/pretty-format/rollup.config.js
  67. +2 −2 packages/runner/package.json
  68. +6 −3 packages/runner/rollup.config.js
  69. +16 −6 packages/runner/src/context.ts
  70. +54 −8 packages/runner/src/hooks.ts
  71. +4 −2 packages/runner/src/suite.ts
  72. +5 −1 packages/runner/src/types/tasks.ts
  73. +2 −1 packages/runner/src/utils/tasks.ts
  74. +3 −3 packages/snapshot/package.json
  75. +6 −3 packages/snapshot/rollup.config.js
  76. +1 −1 packages/snapshot/src/port/state.ts
  77. +1 −1 packages/spy/package.json
  78. +6 −3 packages/spy/rollup.config.js
  79. +1 −1 packages/ui/client/components/FileDetails.vue
  80. +1 −1 packages/ui/client/components/explorer/ExplorerItem.vue
  81. +2 −2 packages/ui/client/composables/explorer/collapse.ts
  82. +5 −3 packages/ui/client/composables/explorer/collector.ts
  83. +1 −1 packages/ui/client/composables/explorer/expand.ts
  84. +3 −3 packages/ui/client/composables/explorer/filter.ts
  85. +2 −1 packages/ui/client/test.ts
  86. +16 −16 packages/ui/package.json
  87. +14 −11 packages/ui/rollup.config.js
  88. +4 −4 packages/utils/package.json
  89. +6 −3 packages/utils/rollup.config.js
  90. +4 −4 packages/utils/src/diff/cleanupSemantic.ts
  91. +3 −0 packages/utils/src/display.ts
  92. +2 −1 packages/utils/src/error.ts
  93. +4 −2 packages/utils/src/highlight.ts
  94. +7 −7 packages/vite-node/package.json
  95. +9 −4 packages/vite-node/rollup.config.js
  96. +4 −0 packages/vite-node/src/cli.ts
  97. +1 −1 packages/vite-node/src/client.ts
  98. +1 −1 packages/vite-node/src/server.ts
  99. +2 −2 packages/vite-node/src/source-map-handler.ts
  100. +18 −18 packages/vitest/package.json
  101. +12 −8 packages/vitest/rollup.config.js
  102. +1 −1 packages/vitest/src/api/check.ts
  103. +1 −1 packages/vitest/src/integrations/chai/poll.ts
  104. +5 −74 packages/vitest/src/integrations/coverage.ts
  105. +2 −2 packages/vitest/src/integrations/mock/timers.ts
  106. +2 −1 packages/vitest/src/node/cli/cac.ts
  107. +1 −1 packages/vitest/src/node/cli/cli-api.ts
  108. +5 −0 packages/vitest/src/node/config/serializeConfig.ts
  109. +1 −1 packages/vitest/src/node/core.ts
  110. +717 −0 packages/vitest/src/node/coverage.ts
  111. +3 −0 packages/vitest/src/node/error.ts
  112. +1 −0 packages/vitest/src/node/plugins/publicConfig.ts
  113. +39 −3 packages/vitest/src/node/pools/rpc.ts
  114. +4 −2 packages/vitest/src/node/project.ts
  115. +1 −1 packages/vitest/src/node/reporters/benchmark/tableRender.ts
  116. +4 −2 packages/vitest/src/node/reporters/index.ts
  117. +1 −0 packages/vitest/src/node/reporters/junit.ts
  118. +7 −7 packages/vitest/src/node/reporters/reported-tasks.ts
  119. +1 −1 packages/vitest/src/node/reporters/summary.ts
  120. +1 −1 packages/vitest/src/node/spec.ts
  121. +1 −1 packages/vitest/src/node/specifications.ts
  122. +3 −20 packages/vitest/src/node/types/coverage.ts
  123. +3 −2 packages/vitest/src/node/workspace/resolveWorkspace.ts
  124. +0 −1 packages/vitest/src/public/browser.ts
  125. +1 −1 packages/vitest/src/public/coverage.ts
  126. +1 −1 packages/vitest/src/runtime/benchmark.ts
  127. +4 −0 packages/vitest/src/runtime/config.ts
  128. +0 −1 packages/vitest/src/runtime/runners/test.ts
  129. +1 −0 packages/vitest/src/typecheck/collect.ts
  130. +2 −1 packages/vitest/src/utils/colors.ts
  131. +49 −657 packages/vitest/src/utils/coverage.ts
  132. +3 −3 packages/web-worker/package.json
  133. +11 −7 packages/web-worker/rollup.config.js
  134. +5 −2 packages/web-worker/src/shared-worker.ts
  135. +3 −1 packages/web-worker/src/worker.ts
  136. +4 −4 packages/ws-client/package.json
  137. +8 −4 packages/ws-client/rollup.config.js
  138. +0 −1 packages/ws-client/src/index.ts
  139. +1,144 −1,030 pnpm-lock.yaml
  140. +39 −0 pnpm-workspace.yaml
  141. +67 −0 scripts/build-utils.js
  142. +1 −0 test/browser/package.json
  143. +15 −2 test/browser/specs/runner.test.ts
  144. +13 −2 test/browser/test/failing.test.ts
  145. +11 −0 test/cli/deps/error/index.js
  146. +9 −0 test/cli/deps/error/package.json
  147. +9 −0 test/cli/deps/error/transpiled-inline.js
  148. +26 −0 test/cli/deps/error/transpiled-inline.ts
  149. +9 −0 test/cli/deps/error/transpiled.js
  150. +7 −0 test/cli/deps/error/transpiled.js.map
  151. +26 −0 test/cli/deps/error/transpiled.ts
  152. +23 −0 test/cli/deps/error/ts.ts
  153. +1 −0 test/cli/fixtures/custom-pool/pool/custom-pool.ts
  154. +9 −5 test/cli/fixtures/fails/hooks-timeout-before-hook-cleanup-callback.test.ts
  155. +21 −0 test/cli/fixtures/stacktraces/error-in-package.test.js
  156. +2 −1 test/cli/package.json
  157. +137 −0 test/cli/test/__snapshots__/stacktraces.test.ts.snap
  158. +28 −0 test/cli/test/stacktraces.test.ts
  159. +7 −0 test/config/fixtures/get-state/a.test.ts
  160. +7 −0 test/config/fixtures/get-state/b.test.ts
  161. +7 −0 test/config/fixtures/get-state/c.test.ts
  162. +9 −0 test/config/fixtures/get-state/vitest.config.ts
  163. +50 −0 test/config/fixtures/hook-timeout/basic.test.ts
  164. +127 −0 test/config/test/__snapshots__/hook-timeout.test.ts.snap
  165. +6 −4 test/config/test/browser-configs.test.ts
  166. +1 −1 test/config/test/failures.test.ts
  167. +19 −0 test/config/test/get-state.test.ts
  168. +9 −0 test/config/test/hook-timeout.test.ts
  169. +2 −1 test/config/test/override.test.ts
  170. +3 −1 test/config/test/unhandled-rejections.test.ts
  171. +3 −3 test/core/package.json
  172. +5 −2 test/core/src/web-worker/eventListenerWorker.ts
  173. +5 −5 test/core/test/expect-poll.test.ts
  174. +26 −0 test/core/test/jest-expect.test.ts
  175. +49 −0 test/core/test/jest-mock.test.ts
  176. +2 −1 test/core/test/mock-internals.test.ts
  177. +9 −0 test/core/test/utils-display.spec.ts
  178. +19 −0 test/coverage-test/fixtures/configs/vitest.config.conditional.ts
  179. +3 −0 test/coverage-test/fixtures/src/conditional/browser.ts
  180. +3 −0 test/coverage-test/fixtures/src/conditional/node.ts
  181. +1 −1 test/coverage-test/fixtures/test/isolation-1-fixture.test.ts
  182. +4 −4 test/coverage-test/package.json
  183. +0 −83 test/coverage-test/test/__snapshots__/custom-file-covered-1-istanbul.snapshot.json
  184. +0 −128 test/coverage-test/test/__snapshots__/custom-file-covered-1-v8.snapshot.json
  185. +0 −83 test/coverage-test/test/__snapshots__/custom-file-covered-2-istanbul.snapshot.json
  186. +0 −128 test/coverage-test/test/__snapshots__/custom-file-covered-2-v8.snapshot.json
  187. +0 −48 test/coverage-test/test/__snapshots__/custom-file-uncovered-1-istanbul.snapshot.json
  188. +0 −103 test/coverage-test/test/__snapshots__/custom-file-uncovered-1-v8.snapshot.json
  189. +0 −48 test/coverage-test/test/__snapshots__/custom-file-uncovered-2-istanbul.snapshot.json
  190. +0 −103 test/coverage-test/test/__snapshots__/custom-file-uncovered-2-v8.snapshot.json
  191. +0 −503 test/coverage-test/test/__snapshots__/results-istanbul.snapshot.json
  192. +0 −675 test/coverage-test/test/__snapshots__/results-v8.snapshot.json
  193. +33 −1 test/coverage-test/test/all.test.ts
  194. +51 −3 test/coverage-test/test/results-snapshot.test.ts
  195. +73 −13 test/coverage-test/test/workspace.multi-transform.test.ts
  196. +2 −0 test/coverage-test/vitest.workspace.custom.ts
  197. +10 −0 test/reporters/src/data.ts
  198. +3 −0 test/reporters/tests/__snapshots__/html.test.ts.snap
  199. +2 −1 test/reporters/tests/console.test.ts
  200. +1 −0 test/reporters/tests/junit.test.ts
  201. +1 −1 test/reporters/tests/test-run.test.ts
  202. +2 −2 test/snapshots/test/inline-multiple-calls.test.ts
  203. +1 −1 test/snapshots/test/jest-image-snapshot.test.ts
  204. +2 −1 test/test-utils/index.ts
  205. +1 −1 test/test-utils/package.json
  206. +2 −1 test/typescript/test-d/test.test-d.ts
  207. +2 −1 test/ui/test/ui.spec.ts
  208. +1 −1 test/vite-node/src/deps.ts
  209. +10 −0 test/vite-node/test/cli.test.ts
  210. +5 −0 test/vite-node/test/hmr.test.ts
  211. +2 −1 test/vite-node/test/server.test.ts
  212. +1 −1 test/workspaces/package.json
2 changes: 1 addition & 1 deletion .github/actions/setup-and-cache/action.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ runs:

steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Set node version to ${{ inputs.node-version }}
uses: actions/setup-node@v4
17 changes: 3 additions & 14 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -8,25 +8,14 @@
"groupName": "Eslint packages",
"matchPackageNames": ["/eslint/"]
},
{
"groupName": "Playwright packages",
"matchPackageNames": ["/playwright/"]
},
{
"depTypeList": ["peerDependencies"],
"enabled": false
},
{
"matchPaths": [
"test/**",
"examples/**"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"groupName": "all non-major examples dependencies",
"groupSlug": "all-minor-patch-examples"
"matchDepTypes": ["action"],
"excludePackagePrefixes": ["actions/", "github/"],
"pinDigests": true
}
],
"ignoreDeps": [
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ jobs:
with:
node-version: ${{ matrix.node_version }}

- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # v1.7.3

- name: Install
run: pnpm i
@@ -139,8 +139,8 @@ jobs:
with:
node-version: 20

- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-firefox@v1
- uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # v1.7.3
- uses: browser-actions/setup-firefox@634a60ccd6599686158cf5a570481b4cd30455a2 # v1.5.4

- name: Install
run: pnpm i
2 changes: 1 addition & 1 deletion .github/workflows/cr.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Set node version to 20
uses: actions/setup-node@v4
2 changes: 1 addition & 1 deletion .github/workflows/ecosystem-ci-trigger.yml
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ jobs:
repo: pr.head.repo.full_name
}
- id: generate-token
uses: tibdex/github-app-token@v2
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_ID }}
installation_retrieval_payload: '${{ github.repository_owner }}/vitest-ecosystem-ci'
2 changes: 1 addition & 1 deletion .github/workflows/issue-close-require.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: needs reproduction
uses: actions-cool/issues-helper@v3
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0
with:
actions: close-issues
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
steps:
- name: needs reproduction
if: github.event.label.name == 'needs reproduction'
uses: actions-cool/issues-helper@v3
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0
with:
actions: create-comment
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
if: github.repository == 'vitest-dev/vitest'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-inactive-days: '14'
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Set node version to 20
uses: actions/setup-node@v4
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ export default ({ mode }: { mode: string }) => {
},
}),
],
languages: ['js', 'jsx', 'ts', 'tsx'],
},
themeConfig: {
logo: '/logo.svg',
4 changes: 2 additions & 2 deletions docs/advanced/api/reporters.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ function onInit(vitest: Vitest): Awaitable<void>
This method is called when [Vitest](/advanced/api/vitest) was initiated or started, but before the tests were filtered.

::: info
Internally this method is called inside [`vitest.start`](/advanced/api/vitest#start), [`vitest.init`](/advanced/api/vitest#init) or [`vitest.mergeReports`](/advanced/api/vitest#mergereports). If you are using programmatic API, make sure to call either one dependning on your needs before calling [`vitest.runTestSpecifications`](/advanced/api/vitest#runtestspecifications), for example. Built-in CLI will always run methods in correct order.
Internally this method is called inside [`vitest.start`](/advanced/api/vitest#start), [`vitest.init`](/advanced/api/vitest#init) or [`vitest.mergeReports`](/advanced/api/vitest#mergereports). If you are using programmatic API, make sure to call either one depending on your needs before calling [`vitest.runTestSpecifications`](/advanced/api/vitest#runtestspecifications), for example. Built-in CLI will always run methods in correct order.
:::

Note that you can also get access to `vitest` instance from test cases, suites and test modules via a [`project`](/advanced/api/test-project) property, but it might also be useful to store a reference to `vitest` in this method.
@@ -139,7 +139,7 @@ The third argument indicated why the test run was finished:

- `passed`: test run was finished normally and there are no errors
- `failed`: test run has at least one error (due to a syntax error during collection or an actual error during test execution)
- `interrupted`: test was interruped by [`vitest.cancelCurrentRun`](/advanced/api/vitest#cancelcurrentrun) call or `Ctrl+C` was pressed in the terminal (note that it's still possible to have failed tests in this case)
- `interrupted`: test was interrupted by [`vitest.cancelCurrentRun`](/advanced/api/vitest#cancelcurrentrun) call or `Ctrl+C` was pressed in the terminal (note that it's still possible to have failed tests in this case)

If Vitest didn't find any test files to run, this event will be invoked with empty arrays of modules and errors, and the state will depend on the value of [`config.passWithNoTests`](/config/#passwithnotests).

2 changes: 1 addition & 1 deletion docs/advanced/api/test-project.md
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ const value = inject('key')
```
:::

The values can be provided dynamicaly. Provided value in tests will be updated on their next run.
The values can be provided dynamically. Provided value in tests will be updated on their next run.

::: tip
This method is also available to [global setup files](/config/#globalsetup) for cases where you cannot use the public API:
2 changes: 1 addition & 1 deletion docs/advanced/api/test-specification.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ The ID of the module in Vite's module graph. Usually, it's an absolute file path

## testModule

Instance of [`TestModule`](/advanced/api/test-module) assosiated with the specification. If test wasn't queued yet, this will be `undefined`.
Instance of [`TestModule`](/advanced/api/test-module) associated with the specification. If test wasn't queued yet, this will be `undefined`.

## pool <Badge type="warning">experimental</Badge> {#pool}

12 changes: 6 additions & 6 deletions docs/advanced/api/vitest.md
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ In the future, the old API won't be exposed anymore.

The global snapshot manager. Vitest keeps track of all snapshots using the `snapshot.add` method.

You can get the latest summary of snapshots via the `vitest.snapshot.summay` property.
You can get the latest summary of snapshots via the `vitest.snapshot.summary` property.

## cache

@@ -130,7 +130,7 @@ function provide<T extends keyof ProvidedContext & string>(

Vitest exposes `provide` method which is a shorthand for `vitest.getRootProject().provide`. With this method you can pass down values from the main thread to tests. All values are checked with `structuredClone` before they are stored, but the values themselves are not cloned.

To recieve the values in the test, you need to import `inject` method from `vitest` entrypont:
To receive the values in the test, you need to import `inject` method from `vitest` entrypoint:

```ts
import { inject } from 'vitest'
@@ -155,7 +155,7 @@ declare module 'vitest' {
```

::: warning
Technically, `provide` is a method of [`TestProject`](/advanced/api/test-project), so it is limited to the specific project. However, all projects inherit the values from the core project which makes `vitest.provide` universal way of passing down values to tests.
Technically, `provide` is a method of [`TestProject`](/advanced/api/test-project), so it is limited to the specific project. However, all projects inherit the values from the root project which makes `vitest.provide` universal way of passing down values to tests.
:::

## getProvidedContext
@@ -172,7 +172,7 @@ This returns the root context object. This is a shorthand for `vitest.getRootPro
function getProjectByName(name: string): TestProject
```

This method returns the project by its name. Simillar to calling `vitest.projects.find`.
This method returns the project by its name. Similar to calling `vitest.projects.find`.

::: warning
In case the project doesn't exist, this method will return the root project - make sure to check the names again if the project you are looking for is the one returned.
@@ -297,7 +297,7 @@ As of Vitest 3, this method uses a cache to check if the file is a test. To make
function clearSpecificationsCache(moduleId?: string): void
```

Vitest automatically caches test specifications for each file when [`globTestSpecifications`](#globtestspecifications) or [`runTestSpecifications`](#runtestspecifications) is called. This method clears the cache for the given file or the whole cache alltogether depending on the first argument.
Vitest automatically caches test specifications for each file when [`globTestSpecifications`](#globtestspecifications) or [`runTestSpecifications`](#runtestspecifications) is called. This method clears the cache for the given file or the whole cache altogether depending on the first argument.

## runTestSpecifications

@@ -452,7 +452,7 @@ function exit(force = false): Promise<void>

Closes all projects and exit the process. If `force` is set to `true`, the process will exit immediately after closing the projects.

This method will also forcefuly call `process.exit()` if the process is still active after [`config.teardownTimeout`](/config/#teardowntimeout) milliseconds.
This method will also forcefully call `process.exit()` if the process is still active after [`config.teardownTimeout`](/config/#teardowntimeout) milliseconds.

## shouldKeepServer

4 changes: 2 additions & 2 deletions docs/advanced/guide/tests.md
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ finally {
}
```

If you intend to keep the `Vitest` instance, make sure to at least call [`init`](/advanced/api/vitest#init). This will initialise reporters and the coverage provider, but won't run any tests. It is also recommended to enable the `watch` mode even if you don't intend to use the Vitest watcher, but want to keep the instance running. Vitest relies on this flag for some of its features to work correctly in a continous process.
If you intend to keep the `Vitest` instance, make sure to at least call [`init`](/advanced/api/vitest#init). This will initialise reporters and the coverage provider, but won't run any tests. It is also recommended to enable the `watch` mode even if you don't intend to use the Vitest watcher, but want to keep the instance running. Vitest relies on this flag for some of its features to work correctly in a continuous process.

After reporters are initialised, use [`runTestSpecifications`](/advanced/api/vitest#runtestspecifications) or [`rerunTestSpecifications`](/advanced/api/vitest#reruntestspecifications) to run tests if manual run is required:

@@ -88,7 +88,7 @@ watcher.on('change', async (file) => {
```

::: warning
The example above shows a potential usecase if you disable the default watcher behaviour. By default, Vitest already reruns tests if files change.
The example above shows a potential use-case if you disable the default watcher behaviour. By default, Vitest already reruns tests if files change.

Also note that `getModuleSpecifications` will not resolve test files unless they were already processed by `globTestSpecifications`. If the file was just created, use `project.matchesGlobPattern` instead:

51 changes: 49 additions & 2 deletions docs/api/mock.md
Original file line number Diff line number Diff line change
@@ -52,6 +52,21 @@ function mockClear(): MockInstance<T>

Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions.

```ts
const person = {
greet: (name: string) => `Hello ${name}`,
}
const spy = vi.spyOn(person, 'greet').mockImplementation(() => 'mocked')
expect(person.greet('Alice')).toBe('mocked')
expect(spy.mock.calls).toEqual([['Alice']])
// clear call history but keep mock implementation
spy.mockClear()
expect(spy.mock.calls).toEqual([])
expect(person.greet('Bob')).toBe('mocked')
expect(spy.mock.calls).toEqual([['Bob']])
```

To automatically call this method before each test, enable the [`clearMocks`](/config/#clearmocks) setting in the configuration.

## mockName
@@ -197,14 +212,30 @@ await asyncMock() // throws Error<'Async error'>
function mockReset(): MockInstance<T>
```

Does what `mockClear` does and resets inner implementation to the original function.
Does what [`mockClear`](#mockClear) does and resets inner implementation to the original function.
This also resets all "once" implementations.

Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
resetting a mock from `vi.fn(impl)` will restore implementation to `impl`.

This is useful when you want to reset a mock to its original state.

```ts
const person = {
greet: (name: string) => `Hello ${name}`,
}
const spy = vi.spyOn(person, 'greet').mockImplementation(() => 'mocked')
expect(person.greet('Alice')).toBe('mocked')
expect(spy.mock.calls).toEqual([['Alice']])
// clear call history and reset implementation, but method is still spied
spy.mockReset()
expect(spy.mock.calls).toEqual([])
expect(person.greet).toBe(spy)
expect(person.greet('Bob')).toBe('Hello Bob')
expect(spy.mock.calls).toEqual([['Bob']])
```

To automatically call this method before each test, enable the [`mockReset`](/config/#mockreset) setting in the configuration.

## mockRestore
@@ -213,11 +244,27 @@ To automatically call this method before each test, enable the [`mockReset`](/co
function mockRestore(): MockInstance<T>
```

Does what `mockReset` does and restores original descriptors of spied-on objects.
Does what [`mockReset`](#mockReset) does and restores original descriptors of spied-on objects.

Note that restoring a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
Restoring a mock from `vi.fn(impl)` will restore implementation to `impl`.

```ts
const person = {
greet: (name: string) => `Hello ${name}`,
}
const spy = vi.spyOn(person, 'greet').mockImplementation(() => 'mocked')
expect(person.greet('Alice')).toBe('mocked')
expect(spy.mock.calls).toEqual([['Alice']])
// clear call history and restore spied object method
spy.mockRestore()
expect(spy.mock.calls).toEqual([])
expect(person.greet).not.toBe(spy)
expect(person.greet('Bob')).toBe('Hello Bob')
expect(spy.mock.calls).toEqual([])
```

To automatically call this method before each test, enable the [`restoreMocks`](/config/#restoremocks) setting in the configuration.

## mockResolvedValue
3 changes: 2 additions & 1 deletion docs/guide/browser/interactivity-api.md
Original file line number Diff line number Diff line change
@@ -292,7 +292,7 @@ References:
## userEvent.clear
```ts
function clear(element: Element | Locator): Promise<void>
function clear(element: Element | Locator, options?: UserEventClearOptions): Promise<void>
```

This method clears the input element content.
@@ -451,6 +451,7 @@ References:
function upload(
element: Element | Locator,
files: string[] | string | File[] | File,
options?: UserEventUploadOptions,
): Promise<void>
```

6 changes: 3 additions & 3 deletions docs/guide/browser/locators.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ title: Locators | Browser Mode
outline: [2, 3]
---

# Locators <Version>2.1.0</Version>
# Locators

A locator is a representation of an element or a number of elements. Every locator is defined by a string called a selector. Vitest abstracts this selector by providing convenient methods that generate those selectors behind the scenes.

@@ -381,7 +381,7 @@ It is recommended to use this only after the other locators don't work for your

- `exact: boolean`

Whether the `text` is matched exactly: case-sensetive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.

#### See also

@@ -505,7 +505,7 @@ await page.getByRole('img', { name: 'Rose' }).tripleClick()
### clear

```ts
function clear(): Promise<void>
function clear(options?: UserEventClearOptions): Promise<void>
```

Clears the input element content.
4 changes: 2 additions & 2 deletions docs/guide/browser/multiple-setups.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Since Vitest 3, you can specify several different browser setups using the new [`browser.instances`](/guide/browser/config#browser-instances) option.

The main advatage of using the `browser.instances` over the [workspace](/guide/workspace) is improved caching. Every project will use the same Vite server meaning the file transform and [dependency pre-bundling](https://vite.dev/guide/dep-pre-bundling.html) has to happen only once.
The main advantage of using the `browser.instances` over the [workspace](/guide/workspace) is improved caching. Every project will use the same Vite server meaning the file transform and [dependency pre-bundling](https://vite.dev/guide/dep-pre-bundling.html) has to happen only once.

## Several Browsers

@@ -128,7 +128,7 @@ start tests with --browser=name or --project=name flag. › - Use arrow-keys. Re
firefox
```

If you have several non-headless projects in CI (i.e. the `headless: false` is set manually in the config and not overriden in CI env), Vitest will fail the run and won't start any tests.
If you have several non-headless projects in CI (i.e. the `headless: false` is set manually in the config and not overridden in CI env), Vitest will fail the run and won't start any tests.

The ability to run tests in headless mode is not affected by this. You can still run all instances in parallel as long as they don't have `headless: false`.
:::
2 changes: 1 addition & 1 deletion docs/guide/browser/playwright.md
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ Note that the context is created for every _test file_, not every _test_ like in
:::

::: warning
Vitest awlays sets `ignoreHTTPSErrors` to `true` in case your server is served via HTTPS and `serviceWorkers` to `'allow'` to support module mocking via [MSW](https://mswjs.io).
Vitest always sets `ignoreHTTPSErrors` to `true` in case your server is served via HTTPS and `serviceWorkers` to `'allow'` to support module mocking via [MSW](https://mswjs.io).

It is also recommended to use [`test.browser.viewport`](/guide/browser/config#browser-headless) instead of specifying it here as it will be lost when tests are running in headless mode.
:::
4 changes: 2 additions & 2 deletions docs/guide/improving-performance.md
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ jobs:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Install dependencies
run: pnpm i
@@ -144,7 +144,7 @@ jobs:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- name: Install dependencies
run: pnpm i
Loading