Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 9 additions & 0 deletions api/advanced/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,22 @@ export interface TestAttachment {
path?: string
/** Inline attachment content as a string or raw binary data */
body?: string | Uint8Array
/**
* @experimental
* How the string `body` is encoded.
* - `'base64'` (default): body is already base64-encoded
* - `'utf-8'`: body is a utf8 string
*/
bodyEncoding?: 'base64' | 'utf-8'
}
```

The `TestAttachment` interface represents a file or data attachment associated with a test artifact.

Attachments can be either file-based (via `path`) or inline content (via `body`). The `contentType` helps consumers understand how to interpret the attachment data.

If you pass a string `body`, Vitest assumes it is already base64-encoded unless you set `bodyEncoding: 'utf-8'`. When you pass `body` as a `Uint8Array`, Vitest automatically encodes it as base64. The `bodyEncoding` option only applies to inline `body` attachments, not `path` attachments.

### `TestArtifactLocation`

```ts
Expand Down
18 changes: 18 additions & 0 deletions config/browser/locators.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,22 @@
- **类型:** `string`
- **默认值:** `data-testid`

<<<<<<< HEAD

Check failure on line 15 in config/browser/locators.md

View workflow job for this annotation

GitHub Actions / autofix

Unexpected additional H1 heading found
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve conflict markers in browser locator docs

This commit leaves raw merge-conflict markers (<<<<<<<, =======, >>>>>>>) in the published markdown, which indicates the merge was not completed and will surface broken content to readers; many doc pipelines also fail CI when these markers are present. Please resolve the conflict and keep only the intended final text for this section.

Useful? React with 👍 / 👎.

用于通过 `getByTestId` 定位器查找元素的属性。
=======
Attribute used to find elements with `getByTestId` locator.

## browser.locators.exact <Version type="experimental">4.1.3</Version> {#browser-locators-exact}

- **Type:** `boolean`
- **Default:** `false`

When set to `true`, [locators](/api/browser/locators) will match text exactly by default, requiring a full, case-sensitive match. Individual locator calls can override this default via their own `exact` option.

```ts
// With exact: false (default), this matches "Hello, World!", "Say Hello, World", etc.
// With exact: true, this only matches the string "Hello, World" exactly.
const locator = page.getByText('Hello, World', { exact: true })
await locator.click()
```
>>>>>>> ab4222a4c4bd8d175537000fb1b0f6b7334065c3
7 changes: 7 additions & 0 deletions guide/cli-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ Directory of HTML coverage output to be served in UI mode and HTML reporter.

启用追踪视图模式。 可选项: "on", "off", "on-first-retry", "on-all-retries", "retain-on-failure"

### browser.locators.exact

- **CLI:** `--browser.locators.exact`
- **Config:** [browser.locators.exact](/config/browser/locators#locators-exact)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix broken anchor for browser.locators.exact config link

The new CLI docs link points to /config/browser/locators#locators-exact, but the target section in config/browser/locators.md is explicitly anchored as #browser-locators-exact; clicking this config link will not jump to the option, which makes the new flag harder to discover from the generated CLI page.

Useful? React with 👍 / 👎.


Should locators match the text exactly by default (default: `false`)

### pool

- **命令行终端:** `--pool <pool>`
Expand Down
6 changes: 6 additions & 0 deletions guide/test-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ test('hello world', async ({ annotate }) => {

const file = createTestSpecificFile()
await annotate('creates a file', { body: file })

await annotate('creates a file with text', {
contentType: 'text/markdown',
body: 'Hello **markdown**',
bodyEncoding: 'utf-8',
})
})
```

Expand Down
21 changes: 21 additions & 0 deletions guide/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,28 @@ npx vite preview --outDir ./html
你可以使用 [`outputFile`](/config/outputfile) 配置选项配置输出。你需要在那里指定 `.html` 路径。例如,`./html/index.html` 是默认值。
:::

<<<<<<< HEAD
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove unresolved merge markers from UI guide

The UI guide still contains unresolved conflict markers around the module-graph section, so users will see merge artifacts in the rendered docs and any conflict-marker checks in docs CI can fail. This should be resolved before merging so only the chosen content remains.

Useful? React with 👍 / 👎.

## 模块图 {#module-graph}
=======
::: tip
To view the HTML report from CI, for example in GitHub Actions, upload the output directory as an artifact:

```yaml
- uses: actions/upload-artifact@v4
id: upload-report
with:
name: vitest-report
path: html/

- name: Viewer link in summary
run: echo "[View HTML report](https://viewer.vitest.dev/?url=${{ steps.upload-report.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
```

This adds a link to the job summary. Click it to open the report in [Vitest Viewer](https://viewer.vitest.dev/) directly in the browser. You can also download the artifact manually and extract it, then run `vite preview` locally as above.
:::

## Module Graph
>>>>>>> ab4222a4c4bd8d175537000fb1b0f6b7334065c3

模块图选项卡显示所选测试文件的模块图。

Expand Down
Loading