Skip to content

Commit 5930650

Browse files
committed
!docs: recovery /guide/test-annotations
1 parent 99661d4 commit 5930650

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

guide/environment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Vitest 并不将 `browser` 视作一种测试环境。如果你想让部分测
2727

2828
## 特定文件的环境 {#environments-for-specific-files}
2929

30-
如果配置中设置 `environment` 选项时,它将应用于项目中的所有测试文件。要获得更细粒度的控制,你可以使用控制注释为特定文件指定环境。控制注释是以 `@vitest-environment` 开头,后跟环境名称的注释:
30+
如果在配置文件中设置 `environment` 选项时,它将应用于项目中的所有测试文件。要获得更细粒度的控制,你可以使用控制注释为特定文件指定环境。控制注释是以 `@vitest-environment` 开头,后跟环境名称的注释:
3131

3232
```ts
3333
// @vitest-environment jsdom
@@ -74,7 +74,7 @@ export default <Environment>{
7474
```
7575

7676
::: warning
77-
Vitest 要求环境对象显式提供 `viteEnvironment` 字段(若省略则取 Vitest 环境名)。该字段必须设为 `ssr``client` 或任意自定义 [Vite 环境](https://cn.vite.dev/guide/api-environment) 名称,用于指定处理测试文件的目标环境
77+
Vitest 需要指定环境对象上的 `transformMode` 选项。它应该等于 `ssr``web`。该值决定插件如何转换源代码。如果设置为 `ssr`,则插件挂钩在转换或解析文件时将收到 `ssr: true`。 否则,`ssr` 被设置为 `false`
7878
:::
7979

8080
你还可以通过 `vitest/environments` 访问默认的 Vitest 环境:

guide/test-annotations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ HTML 报告器会以与 UI模式 相同的方式显示测试注释。您可以
8787

8888
### github-actions
8989

90-
`github-actions` 报告器默认会将 [通知消息](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-notice-message) 为通知消息打印。 你可以通过第二个参数配置消息的 `type``notice`, `warning` or `error`。 如果不是这三种类型,Vitest 默认使用消息类型 (notice)。
90+
`github-actions` 报告器默认会将 [通知消息](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-notice-message) 为通知消息打印。 你可以通过第二个参数配置消息的 `type``notice`, `warning` or `error`。 如果不是这三种类型,Vitest 默认使用通知消息 (notice)。
9191

9292
<img alt="GitHub Actions" img-light src="/annotations-gha-light.png">
9393
<img alt="GitHub Actions" img-dark src="/annotations-gha-dark.png">

0 commit comments

Comments
 (0)