Skip to content

Commit 95d8334

Browse files
committed
docs(en): merging all conflicts
2 parents 11955f3 + 19b0a43 commit 95d8334

File tree

6 files changed

+96
-2
lines changed

6 files changed

+96
-2
lines changed

advanced/api/vitest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ This method doesn't trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun
317317
## rerunTestSpecifications
318318

319319
```ts
320-
function runTestSpecifications(
320+
function rerunTestSpecifications(
321321
specifications: TestSpecification[],
322322
allTestsRun = false
323323
): Promise<TestRunResult>

config/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,15 +1073,23 @@ export default defineConfig({
10731073
- **默认值:** `5_000` in Node.js, `15_000` if `browser.enabled` is `true`
10741074
- **命令行终端:** `--test-timeout=5000`, `--testTimeout=5000`
10751075

1076+
<<<<<<< HEAD
10761077
测试的默认超时时间(以毫秒为单位)。
1078+
=======
1079+
Default timeout of a test in milliseconds. Use `0` to disable timeout completely.
1080+
>>>>>>> 19b0a4337b6dcae4c9e5f1792b087e8323194ec1
10771081
10781082
### hookTimeout
10791083

10801084
- **类型:** `number`
10811085
- **默认值:** `10_000` in Node.js, `30_000` if `browser.enabled` is `true`
10821086
- **命令行终端:** `--hook-timeout=10000`, `--hookTimeout=10000`
10831087

1088+
<<<<<<< HEAD
10841089
钩子(hook)的默认超时时间(以毫秒为单位)。
1090+
=======
1091+
Default timeout of a hook in milliseconds. Use `0` to disable timeout completely.
1092+
>>>>>>> 19b0a4337b6dcae4c9e5f1792b087e8323194ec1
10851093
10861094
### teardownTimeout<NonProjectOption />
10871095

guide/browser/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ List of available `browser` options:
101101
- [`browser.screenshotDirectory`](#browser-screenshotdirectory)
102102
- [`browser.screenshotFailures`](#browser-screenshotfailures)
103103

104-
By default, Vitest creates an array with a single element which uses the [`browser.name`](#browser-name) field as a `browser`. Note that this behaviour will be removed with Vitets 4.
104+
By default, Vitest creates an array with a single element which uses the [`browser.name`](#browser-name) field as a `browser`. Note that this behaviour will be removed with Vitest 4.
105105

106106
Under the hood, Vitest transforms these instances into separate [test projects](/advanced/api/test-project) sharing a single Vite server for better caching performance.
107107

guide/browser/locators.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,69 @@ It is recommended to use this only after the other locators don't work for your
387387

388388
- [testing-library's `ByTestId`](https://testing-library.com/docs/queries/bytestid/)
389389

390+
## nth
391+
392+
```ts
393+
function nth(index: number): Locator
394+
```
395+
396+
This method returns a new locator that matches only a specific index within a multi-element query result. Unlike `elements()[n]`, the `nth` locator will be retried until the element is present.
397+
398+
```html
399+
<div aria-label="one"><input/><input/><input/></div>
400+
<div aria-label="two"><input/></div>
401+
```
402+
403+
```tsx
404+
page.getByRole('textbox').nth(0) // ✅
405+
page.getByRole('textbox').nth(4) // ❌
406+
```
407+
408+
::: tip
409+
Before resorting to `nth`, you may find it useful to use chained locators to narrow down your search.
410+
Sometimes there is no better way to distinguish than by element position; although this can lead to flake, it's better than nothing.
411+
:::
412+
413+
```tsx
414+
page.getByLabel('two').getByRole('input') // ✅ better alternative to page.getByRole('textbox').nth(3)
415+
page.getByLabel('one').getByRole('input') // ❌ too ambiguous
416+
page.getByLabel('one').getByRole('input').nth(1) // ✅ pragmatic compromise
417+
```
418+
419+
## first
420+
421+
```ts
422+
function first(): Locator
423+
```
424+
425+
This method returns a new locator that matches only the first index of a multi-element query result.
426+
It is sugar for `nth(0)`.
427+
428+
```html
429+
<input/> <input/> <input/>
430+
```
431+
432+
```tsx
433+
page.getByRole('textbox').first() // ✅
434+
```
435+
436+
## last
437+
438+
```ts
439+
function last(): Locator
440+
```
441+
442+
This method returns a new locator that matches only the last index of a multi-element query result.
443+
It is sugar for `nth(-1)`.
444+
445+
```html
446+
<input/> <input/> <input/>
447+
```
448+
449+
```tsx
450+
page.getByRole('textbox').last() // ✅
451+
```
452+
390453
## Methods
391454

392455
All methods are asynchronous and must be awaited. Since Vitest 3, tests will fail if a method is not awaited.

guide/cli-generated.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ High and low watermarks for functions in the format of `<high>,<low>`
390390

391391
浏览器测试文件是否应并行运行。使用 `--browser.fileParallelism=false` 可禁用 (默认值: `true`)
392392

393+
### browser.connectTimeout
394+
395+
- **CLI:** `--browser.connectTimeout <timeout>`
396+
- **Config:** [browser.connectTimeout](/guide/browser/config#browser-connecttimeout)
397+
398+
If connection to the browser takes longer, the test suite will fail (default: `60_000`)
399+
393400
### pool
394401

395402
- **CLI:** `--pool <pool>`
@@ -654,14 +661,22 @@ VM forks pool 的内存限制。如果你观察到内存泄漏问题,可以尝
654661
- **CLI:** `--testTimeout <timeout>`
655662
- **Config:** [testTimeout](/config/#testtimeout)
656663

664+
<<<<<<< HEAD
657665
测试的默认超时(毫秒)(默认值:`5000`)。
666+
=======
667+
Default timeout of a test in milliseconds (default: `5000`). Use `0` to disable timeout completely.
668+
>>>>>>> 19b0a4337b6dcae4c9e5f1792b087e8323194ec1
658669
659670
### hookTimeout
660671

661672
- **CLI:** `--hookTimeout <timeout>`
662673
- **Config:** [hookTimeout](/config/#hooktimeout)
663674

675+
<<<<<<< HEAD
664676
默认钩子超时(以毫秒为单位)(默认值:`10000`
677+
=======
678+
Default hook timeout in milliseconds (default: `10000`). Use `0` to disable timeout completely.
679+
>>>>>>> 19b0a4337b6dcae4c9e5f1792b087e8323194ec1
665680
666681
### bail
667682

guide/debugging.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ ndb npm run test
2020
```
2121

2222
:::tip
23+
<<<<<<< HEAD
2324
在调试测试时,你可能使用 `--test-timeout` CLI 参数来防止测试在断点处停止时超时。
25+
=======
26+
When debugging tests you might want to use following options:
27+
28+
- [`--test-timeout=0`](/guide/cli#testtimeout) to prevent tests from timing out when stopping at breakpoints
29+
- [`--no-file-parallelism`](/guide/cli#fileparallelism) to prevent test files from running parallel
30+
31+
>>>>>>> 19b0a4337b6dcae4c9e5f1792b087e8323194ec1
2432
:::
2533

2634
## VS Code

0 commit comments

Comments
 (0)