Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
- 向 CLI 传递 `--config` 选项,例如 `vitest --config ./path/to/vitest.config.ts`。
- 使用 `process.env.VITEST` 或在 `defineConfig` 上的 `mode` 属性(如果没有用 `--mode` 覆盖,默认设置为 `test`)也可以在 `vite.config.ts` 中有条件地应用不同的配置。请注意,像任何其他环境变量一样,`VITEST` 也会在测试中的 `import.meta.env` 上暴露出来。

<<<<<<< HEAD

Check failure on line 13 in config/index.md

View workflow job for this annotation

GitHub Actions / autofix

Unexpected additional H1 heading found

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve remaining merge conflict markers

This commit still contains unresolved merge-conflict markers (<<<<<<<, =======, >>>>>>>) here; I also checked the changed docs with rg '^(<<<<<<<|=======|>>>>>>>)' and found the same issue in guide/browser/why.md, guide/learn/writing-tests.md, and guide/migration.md. These markers and the duplicated Chinese/English alternatives would be published as broken documentation, so the conflicts need to be resolved before merging.

Useful? React with 👍 / 👎.

要配置 Vitest 本身,请在我们的 Vite 配置中添加 `test` 属性。如果我们是从 `vite` 本身导入 `defineConfig`,我们还需要在配置文件顶部使用 [三斜杠指令](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) 添加对 Vitest 类型引用。
=======
When an explicit `--config` option is not provided, Vitest looks for `vitest.config.{ts,mts,cts,js,mjs,cjs}` first and `vite.config.{ts,mts,cts,js,mjs,cjs}` second in the project [`root`](/config/root). If no config file is found, Vitest will run without one.

To configure `vitest` itself, add `test` property in your Vite config. You'll also need to add a reference to Vitest types using a [triple slash command](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) at the top of your config file, if you are importing `defineConfig` from `vite` itself.
>>>>>>> 78ee2995b40ef9f8e295c810946ab9b4e3690b6c

如果你尚未使用 `vite` ,可以在配置文件中从 `vitest/config` 导入 `defineConfig`:

Expand Down
6 changes: 6 additions & 0 deletions guide/browser/why.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ outline: deep

### 早期开发 {#early-development}

<<<<<<< HEAD
Vitest 的浏览器模式功能仍处于早期开发阶段。因此,它可能尚未完全优化,可能存在一些尚未解决的错误或问题。建议用户使用独立的浏览器端测试运行程序(如 WebdriverIO、Cypress 或 Playwright)来增强 Vitest 浏览器体验。

### 更长的初始化时间 {#longer-initialization}
=======
### Not a Drop-In Replacement

The browser mode feature of Vitest does not completely replace standalone end-to-end test runners. It is recommended that users augment their Vitest browser experience with a standalone browser-side test runner like WebdriverIO, Cypress or Playwright.
>>>>>>> 78ee2995b40ef9f8e295c810946ab9b4e3690b6c

Vitest 浏览器在初始化过程中需要启动提供程序和浏览器,这可能需要一些时间。与其他测试模式相比,这可能导致更长的初始化时间。
4 changes: 4 additions & 0 deletions guide/learn/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@
})
```

<<<<<<< HEAD

Check failure on line 179 in guide/learn/writing-tests.md

View workflow job for this annotation

GitHub Actions / autofix

Unexpected additional H1 heading found
测试名称中的占位符 `%i`、`%s` 和 `%f` 会被每行中对应的值替换,因此输出会显示 `add(1, 1) -> 2`、`add(1, 2) -> 3` 等。
=======
In the example above, the %i placeholders are replaced with the integer values from each data row. Vitest also supports other placeholder types, such as %s for strings and %f for floating-point numbers. As a result, the test runner generates test names such as add(1, 1) -> 2, add(1, 2) -> 3, and add(2, 1) -> 3.
>>>>>>> 78ee2995b40ef9f8e295c810946ab9b4e3690b6c

如果你的用例包含两个或三个以上的值,传递对象更具可读性。在名称中使用 `$property` 来插入字段:

Expand Down
13 changes: 13 additions & 0 deletions guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,20 @@ await expect.element(banner).toMatchTextContent(/error/i) // [!code ++]
await expect.element(banner).toHaveTextContent('Error!')
```

<<<<<<< HEAD
## 迁移至 Vitest 4.0 {#vitest-4}
=======
### Config Files Are Not Looked Up From Parent Directories

Vitest no longer searches parent directories for config files. If you previously relied on running `vitest` from a subdirectory while using a config file from a parent directory, pass the config explicitly and scope test discovery with `--dir`. For example,

```bash
$ cd subdir && vitest # [!code --]
$ cd subdir && vitest --config ../vitest.config.ts # [!code ++]
```

## Migrating to Vitest 4.0 {#vitest-4}
>>>>>>> 78ee2995b40ef9f8e295c810946ab9b4e3690b6c

::: warning 前提条件
Vitest 4.0 要求 **Vite >= 6.0.0** 和 **Node.js >= 20.0.0**。
Expand Down
Loading