You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
5
+
使用 `browser.instances`的主要优势在于改进了缓存。每个项目将使用同一个 Vite 服务器,这意味着文件转换和[依赖预打包](https://vite.dev/guide/dep-pre-bundling.html)只需要进行一次。
6
6
7
-
## Several Browsers
7
+
## 多个浏览器
8
8
9
-
You can use the `browser.instances`field to specify options for different browsers. For example, if you want to run the same tests in different browsers, the minimal configuration will look like this:
You can also specify different config options independently from the browser (although, the instances _can_ also have `browser`fields):
31
+
你还可以独立于浏览器指定不同的配置选项(尽管,实例也可以有 `browser`字段):
32
32
33
33
::: code-group
34
34
```ts [vitest.config.ts]
@@ -70,15 +70,15 @@ test('ratio works', () => {
70
70
```
71
71
:::
72
72
73
-
In this example Vitest will run all tests in `chromium`browser, but execute a `'./ratio-setup.ts'`file only in the first configuration and inject a different `ratio` value depending on the [`provide`field](/config/#provide).
Note that you need to define the custom `name`value if you are using the same browser name because Vitest will assign the `browser`as the project name otherwise.
You can filter what projects to run with the [`--project`flag](/guide/cli#project). Vitest will automatically assign the browser name as a project name if it is not assigned manually. If the root config already has a name, Vitest will merge them: `custom` -> `custom (browser)`.
Vitest cannot run multiple instances that have `headless`mode set to `false` (the default behaviour). During development, you can select what project to run in your terminal:
? Found multiple projects that run browser tests in headed mode: "chromium", "firefox".
@@ -128,7 +128,7 @@ start tests with --browser=name or --project=name flag. › - Use arrow-keys. Re
128
128
firefox
129
129
```
130
130
131
-
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.
131
+
如果你在 CI 中有多个非无头模式的项目(即在配置中手动设置了 `headless: false`且未在 CI 环境中覆盖),Vitest 将会终止运行并且不会启动任何测试。
132
132
133
-
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`.
0 commit comments