Skip to content

Commit 9b7b8d1

Browse files
authored
Merge pull request #951 from vitest-dev/sync-ab4222a4-1
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ ab4222a
2 parents 683f2fa + 84c7bf5 commit 9b7b8d1

5 files changed

Lines changed: 53 additions & 0 deletions

File tree

api/advanced/artifacts.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,22 @@ export interface TestAttachment {
8282
path?: string
8383
/** Inline attachment content as a string or raw binary data */
8484
body?: string | Uint8Array
85+
/**
86+
* @experimental
87+
* How the string `body` is encoded.
88+
* - `'base64'` (default): body is already base64-encoded
89+
* - `'utf-8'`: body is a utf8 string
90+
*/
91+
bodyEncoding?: 'base64' | 'utf-8'
8592
}
8693
```
8794

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

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

99+
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.
100+
92101
### `TestArtifactLocation`
93102

94103
```ts

config/browser/locators.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@ outline: deep
1313
- **默认值:** `data-testid`
1414

1515
用于通过 `getByTestId` 定位器查找元素的属性。
16+
<!-- TODO: translation -->
17+
## browser.locators.exact <Version type="experimental">4.1.3</Version> {#browser-locators-exact}
18+
19+
- **Type:** `boolean`
20+
- **Default:** `false`
21+
22+
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.
23+
24+
```ts
25+
// With exact: false (default), this matches "Hello, World!", "Say Hello, World", etc.
26+
// With exact: true, this only matches the string "Hello, World" exactly.
27+
const locator = page.getByText('Hello, World', { exact: true })
28+
await locator.click()
29+
```

guide/cli-generated.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,13 @@ Directory of HTML coverage output to be served in UI mode and HTML reporter.
428428
- **配置:** [browser.trace](/config/browser/trace)
429429

430430
启用追踪视图模式。 可选项: "on", "off", "on-first-retry", "on-all-retries", "retain-on-failure"
431+
<!-- TODO: translation -->
432+
### browser.locators.exact
433+
434+
- **CLI:** `--browser.locators.exact`
435+
- **Config:** [browser.locators.exact](/config/browser/locators#locators-exact)
436+
437+
Should locators match the text exactly by default (default: `false`)
431438

432439
### pool
433440

guide/test-annotations.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ test('hello world', async ({ annotate }) => {
1717

1818
const file = createTestSpecificFile()
1919
await annotate('creates a file', { body: file })
20+
21+
await annotate('creates a file with text', {
22+
contentType: 'text/markdown',
23+
body: 'Hello **markdown**',
24+
bodyEncoding: 'utf-8',
25+
})
2026
})
2127
```
2228

guide/ui.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ npx vite preview --outDir ./html
5252

5353
你可以使用 [`outputFile`](/config/outputfile) 配置选项配置输出。你需要在那里指定 `.html` 路径。例如,`./html/index.html` 是默认值。
5454
:::
55+
<!-- TODO: translation -->
56+
::: tip
57+
To view the HTML report from CI, for example in GitHub Actions, upload the output directory as an artifact:
58+
59+
```yaml
60+
- uses: actions/upload-artifact@v4
61+
id: upload-report
62+
with:
63+
name: vitest-report
64+
path: html/
65+
66+
- name: Viewer link in summary
67+
run: echo "[View HTML report](https://viewer.vitest.dev/?url=${{ steps.upload-report.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
68+
```
69+
70+
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.
71+
:::
5572

5673
## 模块图 {#module-graph}
5774

0 commit comments

Comments
 (0)