Skip to content
Merged
Show file tree
Hide file tree
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
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
14 changes: 14 additions & 0 deletions config/browser/locators.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ outline: deep
- **默认值:** `data-testid`

用于通过 `getByTestId` 定位器查找元素的属性。
<!-- TODO: translation -->
## 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()
```
7 changes: 7 additions & 0 deletions guide/cli-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,13 @@ Directory of HTML coverage output to be served in UI mode and HTML reporter.
- **配置:** [browser.trace](/config/browser/trace)

启用追踪视图模式。 可选项: "on", "off", "on-first-retry", "on-all-retries", "retain-on-failure"
<!-- TODO: translation -->
### 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

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
17 changes: 17 additions & 0 deletions guide/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ npx vite preview --outDir ./html

你可以使用 [`outputFile`](/config/outputfile) 配置选项配置输出。你需要在那里指定 `.html` 路径。例如,`./html/index.html` 是默认值。
:::
<!-- TODO: translation -->
::: 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}

Expand Down
Loading