Skip to content

Commit 8ebf639

Browse files
authored
docs(guide/browser/config.md): add some translate
1 parent 1ec2556 commit 8ebf639

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

guide/browser/config.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default defineConfig({
139139
browser: {
140140
provider: playwright(),
141141
provider: webdriverio(),
142-
provider: preview(), // default
142+
provider: preview(), // 默认
143143
},
144144
},
145145
})
@@ -153,7 +153,7 @@ import { playwright } from '@vitest/browser-playwright'
153153
export default defineConfig({
154154
test: {
155155
browser: {
156-
// shared provider options between all instances
156+
// 所有实例之间共享提供者的选项
157157
provider: playwright({
158158
launchOptions: {
159159
slowMo: 50,
@@ -165,8 +165,8 @@ export default defineConfig({
165165
{ browser: 'chromium' },
166166
{
167167
browser: 'firefox',
168-
// overriding options only for a single instance
169-
// this will NOT merge options with the parent one
168+
// 仅为单个实例覆盖选项
169+
// 这不会将选项与父选项合并
170170
provider: playwright({
171171
launchOptions: {
172172
firefoxUserPrefs: {
@@ -181,7 +181,7 @@ export default defineConfig({
181181
})
182182
```
183183

184-
### Custom Provider <Badge type="danger">advanced</Badge>
184+
### 自定义提供者 <Badge type="danger">高级</Badge>
185185

186186
::: danger ADVANCED API
187187
自定义提供者 API 高度实验性,并且可能在补丁版本之间发生变化。如果你只需要在浏览器中运行测试,请改用 [`browser.instances`](#browser-instances) 选项。
@@ -192,7 +192,7 @@ export interface BrowserProvider {
192192
name: string
193193
mocker?: BrowserModuleMocker
194194
/**
195-
* @experimental opt-in into file parallelisation
195+
* @experimental 选择进入文件并行化
196196
*/
197197
supportsParallelism: boolean
198198
getCommandsContext: (sessionId: string) => Record<string, unknown>
@@ -304,44 +304,44 @@ export interface BrowserScript {
304304

305305
- **类型:** `'on' | 'off' | 'on-first-retry' | 'on-all-retries' | 'retain-on-failure' | object`
306306
- **CLI:** `--browser.trace=on`, `--browser.trace=retain-on-failure`
307-
- **Default:** `'off'`
307+
- **默认:** `'off'`
308308

309-
Capture a trace of your browser test runs. You can preview traces with [Playwright Trace Viewer](https://trace.playwright.dev/).
309+
捕获浏览器测试运行的跟踪。您可以使用 [Playwright 跟踪查看器](https://trace.playwright.dev/) 预览跟踪。
310310

311-
This options supports the following values:
311+
该选项支持以下值:
312312

313-
- `'on'` - capture trace for all tests. (not recommended as it's performance heavy)
314-
- `'off'` - do not capture traces.
315-
- `'on-first-retry'` - capture trace only when retrying the test for the first time.
316-
- `'on-all-retries'` - capture trace on every retry of the test.
317-
- `'retain-on-failure'` - capture trace only for tests that fail. This will automatically delete traces for tests that pass.
318-
- `object` - an object with the following shape:
313+
- `'on'` - 捕捉所有测试的跟踪。(不建议使用,因为性能较差)
314+
- `'off'` - 不捕捉痕迹。
315+
- `'on-first-retry'` - 仅在第一次重试测试时捕捉跟踪。
316+
- `'on-all-retries'` - 在每次重试测试时捕捉跟踪。
317+
- `'retain-on-failure'` - 只捕捉失败测试的跟踪。这会自动删除通过的测试跟踪。
318+
- `object` - 一个具有以下样子的对象
319319

320320
```ts
321321
interface TraceOptions {
322322
mode: 'on' | 'off' | 'on-first-retry' | 'on-all-retries' | 'retain-on-failure'
323323
/**
324-
* The directory where all traces will be stored. By default, Vitest
325-
* stores all traces in `__traces__` folder close to the test file.
324+
* 存储所有痕迹的目录。默认情况下,Vitest
325+
* 将所有跟踪记录存储在靠近测试文件的 `__traces__` 文件夹中。
326326
*/
327327
tracesDir?: string
328328
/**
329-
* Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.
329+
* 是否在跟踪过程中截图。截图用于建立时间线预览。
330330
* @default true
331331
*/
332332
screenshots?: boolean
333333
/**
334-
* If this option is true tracing will
335-
* - capture DOM snapshot on every action
336-
* - record network activity
334+
* 如果该选项为真,跟踪将
335+
* - 捕捉每个操作的 DOM 快照
336+
* - 记录网络活动
337337
* @default true
338338
*/
339339
snapshots?: boolean
340340
}
341341
```
342342

343343
::: danger WARNING
344-
This option is supported only by the [**playwright**](/guide/browser/playwright) provider.
344+
只有 [**playwright**](/guide/browser/playwright) 提供者支持该选项。
345345
:::
346346

347347
## browser.trackUnhandledErrors
@@ -396,7 +396,7 @@ export default defineConfig({
396396
#### browser.expect.toMatchScreenshot.resolveScreenshotPath
397397

398398
- **类型:** `(data: PathResolveData) => string`
399-
- **Default output:** `` `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
399+
- **默认输出:** `` `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
400400

401401
一个用于自定义参考截图存储位置的函数。该函数接收一个包含以下属性的对象:
402402

@@ -466,7 +466,7 @@ resolveScreenshotPath: ({ arg, browserName, ext, root, testFileName }) =>
466466
#### browser.expect.toMatchScreenshot.resolveDiffPath
467467

468468
- **类型:** `(data: PathResolveData) => string`
469-
- **Default output:** `` `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
469+
- **默认输出:** `` `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` ``
470470

471471
一个用于自定义截图比较失败时差异图像存储位置的函数。它接收与 [`resolveScreenshotPath`](#browser-expect-tomatchscreenshot-resolvescreenshotpath) 相同的数据对象。
472472

0 commit comments

Comments
 (0)