Skip to content
Merged
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
8 changes: 4 additions & 4 deletions guide/browser/preview.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Configuring Preview
# 配置预览

::: warning
The `preview` provider's main functionality is to show tests in a real browser environment. However, it does not support advanced browser automation features like multiple browser instances or headless mode. For more complex scenarios, consider using [Playwright](/guide/browser/playwright) or [WebdriverIO](/guide/browser/webdriverio).
`preview` 提供程序的主要功能是在真实浏览器环境中显示测试。不过,它不支持高级浏览器自动化功能,如多个浏览器实例或无头模式。对于更复杂的场景,请考虑使用 [Playwright](/guide/browser/playwright) [WebdriverIO](/guide/browser/webdriverio)
:::

To see your tests running in a real browser, you need to install the [`@vitest/browser-preview`](https://www.npmjs.com/package/@vitest/browser-preview) npm package and specify its `preview` export in the `test.browser.provider` property of your config:
要查看测试在真实浏览器中的运行情况,需要安装 [`@vitest/browser-preview`](https://www.npmjs.com/package/@vitest/browser-preview) npm 软件包,并在配置的 `test.browser.provider` 属性中指定其 `preview` 导出:

```ts [vitest.config.js]
import { preview } from '@vitest/browser-preview'
Expand All @@ -20,7 +20,7 @@ export default defineConfig({
})
```

This will open a new browser window using your default browser to run the tests. You can configure which browser to use by setting the `browser` property in the `instances` array. Vitest will try to open that browser automatically, but it might not work in some environments. In that case, you can manually open the provided URL in your desired browser.
这将使用默认浏览器打开一个新的浏览器窗口来运行测试。您可以通过设置 `instances` 数组中的 `browser` 属性来配置使用哪个浏览器。Vitest 会尝试自动打开浏览器,但在某些环境下可能无法正常工作。在这种情况下,您可以在所需的浏览器中手动打开所提供的 URL

## 与其他 Providers 的差异

Expand Down