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
20 changes: 20 additions & 0 deletions api/expect-typeof.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,23 @@ expectTypeOf(obj).toHaveProperty('a').toBeNumber()
expectTypeOf(obj).toHaveProperty('b').toBeString()
expectTypeOf(obj).toHaveProperty('a').not.toBeString()
```

## branded

- **Type:** `ExpectTypeOf<BrandedType>`

You can use `.branded` to allow type assertions to succeed for types that are semantically equivalent but differ in representation.

```ts
import { expectTypeOf } from 'vitest'

// Without .branded, this fails even though the types are effectively the same
expectTypeOf<{ a: { b: 1 } & { c: 1 } }>().toEqualTypeOf<{ a: { b: 1; c: 1 } }>()

// With .branded, the assertion succeeds
expectTypeOf<{ a: { b: 1 } & { c: 1 } }>().branded.toEqualTypeOf<{ a: { b: 1; c: 1 } }>()
```

::: warning
This helper comes at a performance cost and can cause the TypeScript compiler to 'give up' if used with excessively deep types. Use it sparingly and only when necessary.
:::
12 changes: 12 additions & 0 deletions config/experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ outline: deep

## experimental.fsModuleCache <Version type="experimental">4.0.11</Version> {#experimental-fsmodulecache}

::: tip 功能反馈
请将关于此功能反馈提交至 [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions/9221)。
:::

- **Type:** `boolean`
- **Default:** `false`

Expand Down Expand Up @@ -103,6 +107,10 @@ At the moment, Vitest ignores the [test.cache.dir](/config/cache) or [cacheDir](

## experimental.openTelemetry <Version type="experimental">4.0.11</Version> {#experimental-opentelemetry}

::: tip 功能反馈
请将关于此功能反馈提交至 [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions/9222)。
:::

- **Type:**

```ts
Expand Down Expand Up @@ -168,6 +176,10 @@ It's important that Node can process `sdkPath` content because it is not transfo

## experimental.printImportBreakdown <Version type="experimental">4.0.15</Version> {#experimental-printimportbreakdown}

::: tip 功能反馈
请将关于此功能反馈提交至 [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions/9224)。
:::

- **Type:** `boolean`
- **Default:** `false`

Expand Down
2 changes: 1 addition & 1 deletion config/onstacktrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ outline: deep

- **Type**: `(error: Error, frame: ParsedStack) => boolean | void`

Apply a filtering function to each frame of each stack trace when handling errors. This does not apply to stack traces printed by [`printConsoleTrace`](#printConsoleTrace). The first argument, `error`, is a `TestError`.
Apply a filtering function to each frame of each stack trace when handling errors. This does not apply to stack traces printed by [`printConsoleTrace`](/config/printconsoletrace#printconsoletrace). The first argument, `error`, is a `TestError`.

Can be useful for filtering out stack trace frames from third-party libraries.

Expand Down
6 changes: 4 additions & 2 deletions guide/open-telemetry.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Open Telemetry Support <Experimental /> {#open-telemetry-support}

::: tip Example Project
::: tip 功能反馈
请将关于此功能反馈提交至 [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions/9222)。
:::

::: tip 示例项目
[GitHub](https://github.com/vitest-dev/vitest/tree/main/examples/opentelemetry)

:::

[OpenTelemetry](https://opentelemetry.io/) traces can be a useful tool to debug the performance and behavior of your application inside tests.
Expand Down
4 changes: 4 additions & 0 deletions guide/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ npx vite preview --outDir ./html

### 导入耗时分析 {#import-breakdown}

::: tip 功能反馈
请将关于此功能反馈提交至 [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions/9224)。
:::

模块图选项卡还会提供导入耗时分析功能,默认显示加载时间最长的10个模块(点击"显示更多"可追加10个),按总耗时排序。

<img alt="Import breakdown with a list of top 10 modules that take the longest time to load" img-light src="/ui/light-import-breakdown.png">
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ publish = ".vitepress/dist"
command = "npx pnpm i --ignore-scripts && pnpm run build"

[build.environment]
NODE_VERSION = "20"
NODE_VERSION = "24"

[[redirects]]
from = "https://cn-vitest.netlify.app/*"
Expand Down