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
16 changes: 16 additions & 0 deletions api/advanced/test-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,19 @@ function artifacts(): ReadonlyArray<TestArtifact>
```

通过 `recordArtifact` API,在测试执行过程中记录的 [测试产物](/api/advanced/artifacts)。
<!-- TODO: translation -->
## toTestSpecification <Version>4.1.0</Version> {#totestspecification}

```ts
function toTestSpecification(): TestSpecification
```

Returns a new [test specification](/api/advanced/test-specification) that can be used to filter or run this specific test case.

## logs <Version>5.0.0</Version> {#logs}

```ts
function logs(): ReadonlyArray<UserConsoleLog>
```

Console logs recorded during the test execution.
30 changes: 25 additions & 5 deletions api/advanced/test-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ if (task.type === 'module') {
'example.test.ts' // ✅
'project\\example.test.ts' // ❌
```
<!-- TODO: translation -->
## viteEnvironment <Version>4.1.0</Version> {#viteenvironment}

This is a Vite's [`DevEnvironment`](https://vite.dev/guide/api-environment) that transforms all files inside of the test module.

::: details History
- `v4.0.15`: added as experimental
:::

## state

Expand Down Expand Up @@ -120,14 +128,26 @@ interface ImportDuration {
totalTime: number
}
```
<!-- TODO: translation -->
## logs <Version>5.0.0</Version> {#logs}

## viteEnvironment <Version>4.1.0</Version> {#viteenvironment}
```ts
function logs(): ReadonlyArray<UserConsoleLog>
```

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

::: details 历史
- `v4.0.15`: 作为实验性功能添加
:::
```ts
console.log('included') // [!code highlight]

describe('suite', () => {
console.log('not included') // [!code error]

test('test', () => {
console.log('not included') // [!code error]
})
})
```

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

Expand Down
22 changes: 22 additions & 0 deletions api/advanced/test-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,28 @@ describe('the validation works correctly', { meta: { decorated: true } }, () =>
:::tip
如果元数据是在收集阶段(而非 `test` 函数内部)附加的,那么它将在 available 的 [`onTestModuleCollected`](./reporters#ontestmodulecollected) 中可用。
:::
<!-- TODO: translation -->
## logs <Version>5.0.0</Version> {#logs}

```ts
function logs(): ReadonlyArray<UserConsoleLog>
```

Console logs recorded during test collection of this suite. For example:

```ts
describe('suite', () => {
console.log('included') // [!code highlight]

beforeAll(() => {
console.log('included') // [!code highlight]
})

test('test', () => {
console.log('not included') // [!code error]
})
})
```

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

Expand Down
Loading