Skip to content

Commit 4393761

Browse files
authored
Merge pull request #970 from vitest-dev/sync-9dac0cd8-1
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ 9dac0cd
2 parents 28847da + c41c5d2 commit 4393761

3 files changed

Lines changed: 63 additions & 5 deletions

File tree

api/advanced/test-case.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,19 @@ function artifacts(): ReadonlyArray<TestArtifact>
292292
```
293293

294294
通过 `recordArtifact` API,在测试执行过程中记录的 [测试产物](/api/advanced/artifacts)。
295+
<!-- TODO: translation -->
296+
## toTestSpecification <Version>4.1.0</Version> {#totestspecification}
297+
298+
```ts
299+
function toTestSpecification(): TestSpecification
300+
```
301+
302+
Returns a new [test specification](/api/advanced/test-specification) that can be used to filter or run this specific test case.
303+
304+
## logs <Version>5.0.0</Version> {#logs}
305+
306+
```ts
307+
function logs(): ReadonlyArray<UserConsoleLog>
308+
```
309+
310+
Console logs recorded during the test execution.

api/advanced/test-module.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ if (task.type === 'module') {
3333
'example.test.ts' //
3434
'project\\example.test.ts' //
3535
```
36+
<!-- TODO: translation -->
37+
## viteEnvironment <Version>4.1.0</Version> {#viteenvironment}
38+
39+
This is a Vite's [`DevEnvironment`](https://vite.dev/guide/api-environment) that transforms all files inside of the test module.
40+
41+
::: details History
42+
- `v4.0.15`: added as experimental
43+
:::
3644

3745
## state
3846

@@ -120,14 +128,26 @@ interface ImportDuration {
120128
totalTime: number
121129
}
122130
```
131+
<!-- TODO: translation -->
132+
## logs <Version>5.0.0</Version> {#logs}
123133

124-
## viteEnvironment <Version>4.1.0</Version> {#viteenvironment}
134+
```ts
135+
function logs(): ReadonlyArray<UserConsoleLog>
136+
```
125137

126-
这是 Vite 的 [`DevEnvironment`](https://cn.vite.dev/guide/api-environment),用于转换测试模块中的所有文件。
138+
Console logs recorded on top level of the module during test collection.For example:
127139

128-
::: details 历史
129-
- `v4.0.15`: 作为实验性功能添加
130-
:::
140+
```ts
141+
console.log('included') // [!code highlight]
142+
143+
describe('suite', () => {
144+
console.log('not included') // [!code error]
145+
146+
test('test', () => {
147+
console.log('not included') // [!code error]
148+
})
149+
})
150+
```
131151

132152
## toTestSpecification <Version>4.1.0</Version> {#totestspecification}
133153

api/advanced/test-suite.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,28 @@ describe('the validation works correctly', { meta: { decorated: true } }, () =>
222222
:::tip
223223
如果元数据是在收集阶段(而非 `test` 函数内部)附加的,那么它将在 available 的 [`onTestModuleCollected`](./reporters#ontestmodulecollected) 中可用。
224224
:::
225+
<!-- TODO: translation -->
226+
## logs <Version>5.0.0</Version> {#logs}
227+
228+
```ts
229+
function logs(): ReadonlyArray<UserConsoleLog>
230+
```
231+
232+
Console logs recorded during test collection of this suite. For example:
233+
234+
```ts
235+
describe('suite', () => {
236+
console.log('included') // [!code highlight]
237+
238+
beforeAll(() => {
239+
console.log('included') // [!code highlight]
240+
})
241+
242+
test('test', () => {
243+
console.log('not included') // [!code error]
244+
})
245+
})
246+
```
225247

226248
## toTestSpecification <Version>4.1.0</Version> {#totestspecification}
227249

0 commit comments

Comments
 (0)