diff --git a/api/advanced/test-case.md b/api/advanced/test-case.md index 8fbccd5a..2a47d435 100644 --- a/api/advanced/test-case.md +++ b/api/advanced/test-case.md @@ -292,3 +292,19 @@ function artifacts(): ReadonlyArray ``` 通过 `recordArtifact` API,在测试执行过程中记录的 [测试产物](/api/advanced/artifacts)。 + +## toTestSpecification 4.1.0 {#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 5.0.0 {#logs} + +```ts +function logs(): ReadonlyArray +``` + +Console logs recorded during the test execution. diff --git a/api/advanced/test-module.md b/api/advanced/test-module.md index 0426f840..6aeb0087 100644 --- a/api/advanced/test-module.md +++ b/api/advanced/test-module.md @@ -33,6 +33,14 @@ if (task.type === 'module') { 'example.test.ts' // ✅ 'project\\example.test.ts' // ❌ ``` + +## viteEnvironment 4.1.0 {#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 @@ -120,14 +128,26 @@ interface ImportDuration { totalTime: number } ``` + +## logs 5.0.0 {#logs} -## viteEnvironment 4.1.0 {#viteenvironment} +```ts +function logs(): ReadonlyArray +``` -这是 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 4.1.0 {#totestspecification} diff --git a/api/advanced/test-suite.md b/api/advanced/test-suite.md index 6cda8e5b..3f664aee 100644 --- a/api/advanced/test-suite.md +++ b/api/advanced/test-suite.md @@ -222,6 +222,28 @@ describe('the validation works correctly', { meta: { decorated: true } }, () => :::tip 如果元数据是在收集阶段(而非 `test` 函数内部)附加的,那么它将在 available 的 [`onTestModuleCollected`](./reporters#ontestmodulecollected) 中可用。 ::: + +## logs 5.0.0 {#logs} + +```ts +function logs(): ReadonlyArray +``` + +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 4.1.0 {#totestspecification}