Skip to content

Commit

Permalink
docs: update content
Browse files Browse the repository at this point in the history
  • Loading branch information
lxKylin committed Jan 10, 2025
1 parent dfdbc58 commit 4ee21c8
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 72 deletions.
5 changes: 0 additions & 5 deletions advanced/guide/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@

Vitest 公开了两种启动 Vitest 的方法:

<<<<<<< HEAD
- `startVitest` 启动 Vitest,验证所需软件包是否已安装并立即运行测试
- `createVitest` 仅启动 Vitest,不运行任何测试
=======
- `startVitest` initiates Vitest, validates the packages are installed and runs tests immediately
- `createVitest` only initiates Vitest and doesn't run any tests
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

## `startVitest`

Expand Down
6 changes: 1 addition & 5 deletions api/expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,7 @@ test('spy function resolves bananas on a last call', async () => {

- **Type**: `(time: number, returnValue: any) => Awaitable<void>`

<<<<<<< HEAD
您可以调用此断言来检查函数在上次调用时是否已成功解析某个值。需要将 spy 函数传递给`expect`
=======
You can call this assertion to check if a function has successfully resolved a certain value on a specific invocation. Requires a spy function to be passed to `expect`.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8
您可以调用此断言来检查函数在特定调用中是否成功解析了某个值。需要将一个间谍函数(spy function)传递给 `expect`

如果函数返回了一个 promise,但尚未 resolved,则将会失败。

Expand Down
6 changes: 1 addition & 5 deletions api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1180,11 +1180,7 @@ afterAll(async () => {

## Test Hooks

<<<<<<< HEAD
Vitest 提供了一些 hooks,你可以在 _测试执行期间_ 调用这些钩子,以便在测试运行结束后清理状态。
=======
Vitest provides a few hooks that you can call _during_ the test execution to cleanup the state when the test has finished running.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8
Vitest 提供了一些 hooks,你可以在 _测试执行期间_ 调用这些 hooks,以便在测试运行结束后清理状态。

::: warning
如果在测试体之外调用这些 hooks ,则会出错。
Expand Down
4 changes: 0 additions & 4 deletions api/vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,7 @@ IntersectionObserver === undefined

## Fake Timers

<<<<<<< HEAD
本节介绍如何使用 [fake timers](/guide/mocking#%E8%AE%A1%E6%97%B6%E5%99%A8)
=======
This sections describes how to work with [fake timers](/guide/mocking#timers).
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

### vi.advanceTimersByTime

Expand Down
7 changes: 0 additions & 7 deletions guide/browser/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,10 @@ declare module '@vitest/browser/context' {

Vitest 在命令上下文中公开了几个`playwright`特定属性。

<<<<<<< HEAD
- `page`引用包含测试 iframe 的完整页面。这是协调器 HTML,为避免出现问题,最好不要碰它。
- `frame` 是一个异步方法,用于解析测试器 [`Frame`](https://playwright.dev/docs/api/class-frame)。它的 API 与 `page` 类似,但不支持某些方法。如果您需要查询元素,应优先使用 `context.iframe` 代替,因为它更稳定、更快速。
- `iframe` 是一个 [`FrameLocator`](https://playwright.dev/docs/api/class-framelocator),用于查询页面上的其他元素。
- `context` 是指唯一的[BrowserContext](https://playwright.dev/docs/api/class-browsercontext)
=======
- `page` references the full page that contains the test iframe. This is the orchestrator HTML and you most likely shouldn't touch it to not break things.
- `frame` is an async method that will resolve tester [`Frame`](https://playwright.dev/docs/api/class-frame). It has a similar API to the `page`, but it doesn't support certain methods. If you need to query an element, you should prefer using `context.iframe` instead because it is more stable and faster.
- `iframe` is a [`FrameLocator`](https://playwright.dev/docs/api/class-framelocator) that should be used to query other elements on the page.
- `context` refers to the unique [BrowserContext](https://playwright.dev/docs/api/class-browsercontext).
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

```ts
import { BrowserCommand } from 'vitest/node'
Expand Down
4 changes: 0 additions & 4 deletions guide/browser/interactivity-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,7 @@ test('update input', async () => {
```

::: info
<<<<<<< HEAD
Vitest 没有像 `input.type` 那样在定位器上公开 `.type` 方法,因为它的存在只是为了与 `userEvent` 库兼容。请考虑使用 `.fill`,因为它更快。
=======
Vitest doesn't expose `.type` method on the locator like `input.type` because it exists only for compatibility with the `userEvent` library. Consider using `.fill` instead as it is faster.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8
:::

相关链接:
Expand Down
32 changes: 0 additions & 32 deletions guide/browser/locators.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ await page.getByRole('button', { name: /submit/i }).click()

- `exact: boolean`

<<<<<<< HEAD
`name` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `name` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `name` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `name` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

```tsx
<button>Hello World</button>
Expand Down Expand Up @@ -217,11 +213,7 @@ page.getByAltText('non existing alt text') // ❌

- `exact: boolean`

<<<<<<< HEAD
`text` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `text` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

#### See also

Expand All @@ -236,11 +228,7 @@ function getByLabelText(
): Locator
```

<<<<<<< HEAD
创建一个能够找到具有关联标签的元素的定位器。
=======
Creates a locator capable of finding an element that has an associated label.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

`page.getByLabelText('Username')` 定位器将在以下示例中找到所有的输入元素:

Expand Down Expand Up @@ -272,11 +260,7 @@ Creates a locator capable of finding an element that has an associated label.

- `exact: boolean`

<<<<<<< HEAD
`text` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `text` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

#### See also

Expand Down Expand Up @@ -308,11 +292,7 @@ page.getByPlaceholder('not found') // ❌

- `exact: boolean`

<<<<<<< HEAD
`text` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `text` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

#### See also

Expand Down Expand Up @@ -344,11 +324,7 @@ page.getByText('about', { exact: true }) // ❌

- `exact: boolean`

<<<<<<< HEAD
`text` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `text` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

#### See also

Expand Down Expand Up @@ -376,11 +352,7 @@ page.getByTitle('Create') // ❌

- `exact: boolean`

<<<<<<< HEAD
`text` 是否精确匹配:区分大小写且完全匹配字符串。默认情况下禁用此选项。如果 `text` 是正则表达式,则忽略此选项。请注意,精确匹配仍然会修剪空白字符。
=======
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

#### See also

Expand Down Expand Up @@ -687,11 +659,7 @@ function query(): Element | null

此方法返回与定位器选择器匹配的单个元素,如果没有找到元素则返回 `null`

<<<<<<< HEAD
如果多个元素匹配该选择器,此方法将抛出错误。如果你需要所有匹配的 DOM 元素,可以使用 [`.elements()`](#elements);如果你需要匹配选择器的定位器数组,可以使用 [`.all()`](#all)。
=======
If multiple elements match the selector, this method will throw an error. Use [`.elements()`](#elements) when you need all matching DOM Elements or [`.all()`](#all) if you need an array of locators matching the selector.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

考虑以下 DOM 结构:

Expand Down
6 changes: 1 addition & 5 deletions guide/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ title: 模拟对象 | 指南
不要忘记在每次测试运行前后清除或恢复模拟对象,以撤消运行测试时模拟对象状态的更改!有关更多信息,请参阅 [`mockReset`](/api/mock.html#mockreset) 文档。
:::

<<<<<<< HEAD
如果我们不熟悉 `vi.fn``vi.mock``vi.spyOn` 方法,请先查看[API部分](/api/vi)
=======
If you are not familiar with `vi.fn`, `vi.mock` or `vi.spyOn` methods, check the [API section](/api/vi) first.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8
如果你不熟悉 `vi.fn``vi.mock``vi.spyOn` 方法,请先查看[API部分](/api/vi)

## 日期

Expand Down
5 changes: 0 additions & 5 deletions guide/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,8 @@ export default defineConfig({

### Blob Reporter

<<<<<<< HEAD
将测试结果存储在计算机上,以便以后可以使用 [`--merge-reports`](/guide/cli#merge-reports) 命令进行合并。
默认情况下,将所有结果存储在 `.vitest-reports` 文件夹中,但可以用 `--outputFile``--outputFile.blob` 标志覆盖。
=======
Stores test results on the machine so they can be later merged using [`--merge-reports`](/guide/cli#merge-reports) command.
By default, stores all results in `.vitest-reports` folder, but can be overridden with `--outputFile` or `--outputFile.blob` flags.
>>>>>>> 658c5b32434bdff1eb68247b26ea2ca7951fe2a8

```bash
npx vitest --reporter=blob --outputFile=reports/blob-1.json
Expand Down

0 comments on commit 4ee21c8

Please sign in to comment.