From 503da9bec420ec9f975c949f77221350f812687e Mon Sep 17 00:00:00 2001 From: noise Date: Tue, 11 Nov 2025 00:50:27 +0800 Subject: [PATCH 1/8] docs: update /guide/assert --- api/assert.md | 488 +++++++++++++++++++------------------- api/expect-typeof.md | 4 +- api/expect.md | 4 +- config/index.md | 12 +- guide/browser/config.md | 10 +- guide/browser/locators.md | 8 +- 6 files changed, 263 insertions(+), 263 deletions(-) diff --git a/api/assert.md b/api/assert.md index d6907123..bbb80112 100644 --- a/api/assert.md +++ b/api/assert.md @@ -1,12 +1,12 @@ # assert -Vitest reexports the `assert` method from [`chai`](https://www.chaijs.com/api/assert/) for verifying invariants. +Vitest 从 [`chai`](https://www.chaijs.com/api/assert/) 重新导出了 `assert` 方法,用于验证不变量。 ## assert -- **Type:** `(expression: any, message?: string) => asserts expression` +- **类型:** `(expression: any, message?: string) => asserts expression` -Assert that the given `expression` is truthy, otherwise the assertion fails. +断言给定的 `expression` 是 true,否则断言失败。 ```ts import { assert, test } from 'vitest' @@ -18,11 +18,11 @@ test('assert', () => { ## fail -- **Type:** +- **类型:** - `(message?: string) => never` - `(actual: T, expected: T, message?: string, operator?: string) => never` -Force an assertion failure. +强制断言失败。 ```ts import { assert, test } from 'vitest' @@ -35,10 +35,10 @@ test('assert.fail', () => { ## isOk -- **Type:** `(value: T, message?: string) => asserts value` +- **类型:** `(value: T, message?: string) => asserts value` - **Alias** `ok` -Assert that the given `value` is truthy. +断言给定的 `value` 是 true。 ```ts import { assert, test } from 'vitest' @@ -51,10 +51,10 @@ test('assert.isOk', () => { ## isNotOk -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` - **Alias** `notOk` -Assert that the given `value` is falsy. +断言给定的 `value` 是 false。 ```ts import { assert, test } from 'vitest' @@ -67,9 +67,9 @@ test('assert.isNotOk', () => { ## equal -- **Type:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` -Asserts non-strict equality (==) of `actual` and `expected`. +断言 `actual` 和 `expected` 非严格相等 (==)。 ```ts import { assert, test } from 'vitest' @@ -81,9 +81,9 @@ test('assert.equal', () => { ## notEqual -- **Type:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` -Asserts non-strict inequality (!=) of `actual` and `expected`. +断言 `actual` 和 `expected` 非严格不等(!=). ```ts import { assert, test } from 'vitest' @@ -95,9 +95,9 @@ test('assert.equal', () => { ## strictEqual -- **Type:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` -Asserts strict equality (===) of `actual` and `expected`. +断言 `actual` 和 `expected` 严格相等 (===)。 ```ts import { assert, test } from 'vitest' @@ -109,9 +109,9 @@ test('assert.strictEqual', () => { ## deepEqual -- **Type:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` -Asserts that `actual` is deeply equal to `expected`. +断言 `actual` 和 `expected` 深度相等。 ```ts import { assert, test } from 'vitest' @@ -123,9 +123,9 @@ test('assert.deepEqual', () => { ## notDeepEqual -- **Type:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` -Assert that `actual` is not deeply equal to `expected`. +断言 `actual` 和 `expected` 不深度相等。 ```ts import { assert, test } from 'vitest' @@ -137,9 +137,9 @@ test('assert.notDeepEqual', () => { ## isAbove -- **Type:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` -Assert that `valueToCheck` is strictly greater than (>) `valueToBeAbove`. +断言 `valueToCheck` 严格大于 (>) `valueToBeAbove`。 ```ts import { assert, test } from 'vitest' @@ -151,9 +151,9 @@ test('assert.isAbove', () => { ## isAtLeast -- **Type:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` -Assert that `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`. +断言 `valueToCheck` 大于等于 (>=) `valueToBeAtLeast`。 ```ts import { assert, test } from 'vitest' @@ -166,9 +166,9 @@ test('assert.isAtLeast', () => { ## isBelow -- **Type:** `(valueToCheck: number, valueToBeBelow: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeBelow: number, message?: string) => void` -Asserts `valueToCheck` is strictly less than (<) `valueToBeBelow`. +断言 `valueToCheck` 严格小于 (<) `valueToBeBelow`。 ```ts import { assert, test } from 'vitest' @@ -180,9 +180,9 @@ test('assert.isBelow', () => { ## isAtMost -- **Type:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` -Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`. +断言 `valueToCheck` 小于等于 (<=) `valueToBeAtMost`。 ```ts import { assert, test } from 'vitest' @@ -195,9 +195,9 @@ test('assert.isAtMost', () => { ## isTrue -- **Type:** `(value: T, message?: string) => asserts value is true` +- **类型:** `(value: T, message?: string) => asserts value is true` -Asserts that `value` is true. +断言 `value` 是 true。 ```ts import { assert, test } from 'vitest' @@ -211,9 +211,9 @@ test('assert.isTrue', () => { ## isNotTrue -- **Type:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` -Asserts that `value` is not true. +断言 `value` 不是 true。 ```ts import { assert, test } from 'vitest' @@ -227,9 +227,9 @@ test('assert.isNotTrue', () => { ## isFalse -- **Type:** `(value: T, message?: string) => asserts value is false` +- **类型:** `(value: T, message?: string) => asserts value is false` -Asserts that `value` is false. +断言 `value` 是 false。 ```ts import { assert, test } from 'vitest' @@ -243,9 +243,9 @@ test('assert.isFalse', () => { ## isNotFalse -- **Type:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` -Asserts that `value` is not false. +断言 `value` 不是 false。 ```ts import { assert, test } from 'vitest' @@ -259,9 +259,9 @@ test('assert.isNotFalse', () => { ## isNull -- **Type:** `(value: T, message?: string) => asserts value is null` +- **类型:** `(value: T, message?: string) => asserts value is null` -Asserts that `value` is null. +断言 `value` 是 null。 ```ts import { assert, test } from 'vitest' @@ -275,9 +275,9 @@ test('assert.isNull', () => { ## isNotNull -- **Type:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` -Asserts that `value` is not null. +断言 `value` 不是 null。 ```ts import { assert, test } from 'vitest' @@ -291,9 +291,9 @@ test('assert.isNotNull', () => { ## isNaN -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is NaN. +断言 `value` 是 NaN。 ```ts import { assert, test } from 'vitest' @@ -307,9 +307,9 @@ test('assert.isNaN', () => { ## isNotNaN -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not NaN. +断言 `value` 不是 NaN。 ```ts import { assert, test } from 'vitest' @@ -323,9 +323,9 @@ test('assert.isNotNaN', () => { ## exists -- **Type:** `(value: T, message?: string) => asserts value is NonNullable` +- **类型:** `(value: T, message?: string) => asserts value is NonNullable` -Asserts that `value` is neither null nor undefined. +断言 `value` 既不是 null 也不是 undefined. ```ts import { assert, test } from 'vitest' @@ -339,9 +339,9 @@ test('assert.exists', () => { ## notExists -- **Type:** `(value: T, message?: string) => asserts value is null | undefined` +- **类型:** `(value: T, message?: string) => asserts value is null | undefined` -Asserts that `value` is either null nor undefined. +断言 `value` 要么是 null 要么是 undefined. ```ts import { assert, test } from 'vitest' @@ -357,9 +357,9 @@ test('assert.notExists', () => { ## isUndefined -- **Type:** `(value: T, message?: string) => asserts value is undefined` +- **类型:** `(value: T, message?: string) => asserts value is undefined` -Asserts that `value` is undefined. +断言 `value` 是 undefined. ```ts import { assert, test } from 'vitest' @@ -373,9 +373,9 @@ test('assert.isUndefined', () => { ## isDefined -- **Type:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` -Asserts that `value` is not undefined. +断言 `value` 不是 undefined. ```ts import { assert, test } from 'vitest' @@ -389,9 +389,9 @@ test('assert.isDefined', () => { ## isFunction -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` - **Alias:** `isCallable` - Asserts that `value` is a function. + 断言 `value` 是一个 function. ```ts import { assert, test } from 'vitest' @@ -407,10 +407,10 @@ test('assert.isFunction', () => { ## isNotFunction -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` - **Alias:** `isNotCallable` -Asserts that `value` is not a function. +断言 `value` 不是一个 function. ```ts import { assert, test } from 'vitest' @@ -424,9 +424,9 @@ test('assert.isNotFunction', () => { ## isObject -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is an object of type Object (as revealed by Object.prototype.toString). The assertion does not match subclassed objects. +断言 `value` 是一个类型为 Object (如 Object.prototype.toString)。 该断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' @@ -440,9 +440,9 @@ test('assert.isObject', () => { ## isNotObject -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not an object of type Object (as revealed by Object.prototype.toString). The assertion does not match subclassed objects. +断言 `value` 不是一个 (如 Object.prototype.toString)。 该断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' @@ -456,9 +456,9 @@ test('assert.isNotObject', () => { ## isArray -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is an array. +断言 `value` 是一个数组。 ```ts import { assert, test } from 'vitest' @@ -472,9 +472,9 @@ test('assert.isArray', () => { ## isNotArray -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not an array. +断言 `value` 不是一个数组。 ```ts import { assert, test } from 'vitest' @@ -488,9 +488,9 @@ test('assert.isNotArray', () => { ## isString -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is a string. +断言 `value` 是一个字符串。 ```ts import { assert, test } from 'vitest' @@ -504,9 +504,9 @@ test('assert.isString', () => { ## isNotString -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not a string. +断言 `value` 不是一个字符串。 ```ts import { assert, test } from 'vitest' @@ -520,9 +520,9 @@ test('assert.isNotString', () => { ## isNumber -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is a number. +断言 `value` 是一个数值。 ```ts import { assert, test } from 'vitest' @@ -536,9 +536,9 @@ test('assert.isNumber', () => { ## isNotNumber -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not a number. +断言 `value` 不是一个数值。 ```ts import { assert, test } from 'vitest' @@ -552,9 +552,9 @@ test('assert.isNotNumber', () => { ## isFinite -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is a finite number (not NaN, Infinity). +断言 `value` 是一个有限数值 (不是 NaN, Infinity)。 ```ts import { assert, test } from 'vitest' @@ -568,9 +568,9 @@ test('assert.isFinite', () => { ## isBoolean -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is a boolean. +断言 `value` 是一个布尔值。 ```ts import { assert, test } from 'vitest' @@ -584,9 +584,9 @@ test('assert.isBoolean', () => { ## isNotBoolean -- **Type:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` -Asserts that `value` is not a boolean. +断言 `value` 不是一个布尔值。 ```ts import { assert, test } from 'vitest' @@ -600,9 +600,9 @@ test('assert.isBoolean', () => { ## typeOf -- **Type:** `(value: T, name: string, message?: string) => void` +- **类型:** `(value: T, name: string, message?: string) => void` -Asserts that `value`’s type is `name`, as determined by Object.prototype.toString. +断言 `value` 的类型是 `name`, 由 Object.prototype.toString 确定。 ```ts import { assert, test } from 'vitest' @@ -619,9 +619,9 @@ test('assert.typeOf', () => { ## notTypeOf -- **Type:** `(value: T, name: string, message?: string) => void` +- **类型:** `(value: T, name: string, message?: string) => void` -Asserts that `value`’s type is not `name`, as determined by Object.prototype.toString. +断言 `value` 的类型不是 `name`,由 Object.prototype.toString 确定。 ```ts import { assert, test } from 'vitest' @@ -633,9 +633,9 @@ test('assert.notTypeOf', () => { ## instanceOf -- **Type:** `(value: T, constructor: Function, message?: string) => asserts value is T` +- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is T` -Asserts that `value` is an instance of `constructor`. +断言 `value` 是 `constructor` 的实例。 ```ts import { assert, test } from 'vitest' @@ -660,9 +660,9 @@ test('assert.instanceOf', () => { ## notInstanceOf -- **Type:** `(value: T, constructor: Function, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is Exclude` -Asserts that `value` is not an instance of `constructor`. +断言 `value` 不是 `constructor` 的实例。 ```ts import { assert, test } from 'vitest' @@ -686,13 +686,13 @@ test('assert.instanceOf', () => { ## include -- **Type:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a value in an array, a substring in a string, or a subset of properties in an object. +断言 `haystack` 包含 `needle`。可用于以下场景:数组中包含某个值、字符串中包含某些字符串、对象中包含属性子集。 ```ts import { assert, test } from 'vitest' @@ -710,13 +710,13 @@ test('assert.include', () => { ## notInclude -- **Type:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -Asserts that `haystack` does not include `needle`. It can be used to assert the absence of a value in an array, a substring in a string, or a subset of properties in an object. +断言 `haystack` 不包含 `needle`。可用于以下场景:数组中包含某个值、字符串中包含某些字符串、对象中包含属性子集。 ```ts import { assert, test } from 'vitest' @@ -734,12 +734,12 @@ test('assert.notInclude', () => { ## deepInclude -- **Type:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used. +断言 `haystack` includes `needle`。 可用于断言数组是否包含某个值,或对象是否包含属性子集。可用于深度比较。 ```ts import { assert, test } from 'vitest' @@ -755,12 +755,12 @@ test('assert.deepInclude', () => { ## notDeepInclude -- **Type:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -Asserts that `haystack` does not include `needle`. It can be used to assert the absence of a value in an array or a subset of properties in an object. Deep equality is used. +断言 `haystack` 不包含 `needle`。可用于断言数组是否包含某个值,或对象是否包含属性子集。可用于深度比较。 ```ts import { assert, test } from 'vitest' @@ -776,9 +776,9 @@ test('assert.notDeepInclude', () => { ## nestedInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. ```ts import { assert, test } from 'vitest' @@ -791,9 +791,9 @@ test('assert.nestedInclude', () => { ## notNestedInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` does not include `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` does not include `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. ```ts import { assert, test } from 'vitest' @@ -806,9 +806,9 @@ test('assert.nestedInclude', () => { ## deepNestedInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. ```ts import { assert, test } from 'vitest' @@ -824,9 +824,9 @@ test('assert.deepNestedInclude', () => { ## notDeepNestedInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. ```ts import { assert, test } from 'vitest' @@ -842,9 +842,9 @@ test('assert.notDeepNestedInclude', () => { ## ownInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties. +断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties. ```ts import { assert, test } from 'vitest' @@ -856,9 +856,9 @@ test('assert.ownInclude', () => { ## notOwnInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties. +断言 `haystack` includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties. ```ts import { assert, test } from 'vitest' @@ -877,9 +877,9 @@ test('assert.notOwnInclude', () => { ## deepOwnInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties and checking for deep equality. +断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties and checking for deep equality. ```ts import { assert, test } from 'vitest' @@ -891,9 +891,9 @@ test('assert.deepOwnInclude', () => { ## notDeepOwnInclude -- **Type:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` -Asserts that `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties and checking for deep equality. +断言 `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties and checking for deep equality. ```ts import { assert, test } from 'vitest' @@ -905,9 +905,9 @@ test('assert.notDeepOwnInclude', () => { ## match -- **Type:** `(value: string, regexp: RegExp, message?: string) => void` +- **类型:** `(value: string, regexp: RegExp, message?: string) => void` -Asserts that `value` matches the regular expression `regexp`. +断言 `value` matches the regular expression `regexp`. ```ts import { assert, test } from 'vitest' @@ -919,9 +919,9 @@ test('assert.match', () => { ## notMatch -- **Type:** `(value: string, regexp: RegExp, message?: string) => void` +- **类型:** `(value: string, regexp: RegExp, message?: string) => void` -Asserts that `value` does not matches the regular expression `regexp`. +断言 `value` does not matches the regular expression `regexp`. ```ts import { assert, test } from 'vitest' @@ -933,9 +933,9 @@ test('assert.notMatch', () => { ## property -- **Type:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` -Asserts that `object` has a direct or inherited property named by `property` +断言 `object` has a direct or inherited property named by `property` ```ts import { assert, test } from 'vitest' @@ -948,9 +948,9 @@ test('assert.property', () => { ## notProperty -- **Type:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` -Asserts that `object` does not have a direct or inherited property named by `property` +断言 `object` does not have a direct or inherited property named by `property` ```ts import { assert, test } from 'vitest' @@ -962,9 +962,9 @@ test('assert.notProperty', () => { ## propertyVal -- **Type:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` -Asserts that `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). +断言 `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -976,9 +976,9 @@ test('assert.notPropertyVal', () => { ## notPropertyVal -- **Type:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` -Asserts that `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). +断言 `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -991,9 +991,9 @@ test('assert.notPropertyVal', () => { ## deepPropertyVal -- **Type:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` -Asserts that `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. +断言 `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1007,9 +1007,9 @@ test('assert.deepPropertyVal', () => { ## notDeepPropertyVal -- **Type:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` -Asserts that `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. +断言 `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1029,9 +1029,9 @@ test('assert.deepPropertyVal', () => { ## nestedProperty -- **Type:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` -Asserts that `object` has a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. +断言 `object` has a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. ```ts import { assert, test } from 'vitest' @@ -1043,9 +1043,9 @@ test('assert.deepPropertyVal', () => { ## notNestedProperty -- **Type:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` -Asserts that `object` does not have a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. +断言 `object` does not have a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. ```ts import { assert, test } from 'vitest' @@ -1057,9 +1057,9 @@ test('assert.deepPropertyVal', () => { ## nestedPropertyVal -- **Type:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` -Asserts that `object` has a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). +断言 `object` has a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1071,9 +1071,9 @@ test('assert.nestedPropertyVal', () => { ## notNestedPropertyVal -- **Type:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` -Asserts that `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). +断言 `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1094,9 +1094,9 @@ test('assert.notNestedPropertyVal', () => { ## deepNestedPropertyVal -- **Type:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` -Asserts that `object` has a property named by `property` with a value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check (===). +断言 `object` has a property named by `property` with a value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check (===). ```ts import { assert, test } from 'vitest' @@ -1117,9 +1117,9 @@ test('assert.notNestedPropertyVal', () => { ## notDeepNestedPropertyVal -- **Type:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` -Asserts that `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check. +断言 `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1145,9 +1145,9 @@ test('assert.notDeepNestedPropertyVal', () => { ## lengthOf -- **Type:** `(object: T, length: number, message?: string) => void` +- **类型:** `(object: T, length: number, message?: string) => void` -Asserts that `object` has a `length` or `size` with the expected value. +断言 `object` has a `length` or `size` with the expected value. ```ts import { assert, test } from 'vitest' @@ -1170,9 +1170,9 @@ test('assert.lengthOf', () => { ## hasAnyKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1199,9 +1199,9 @@ test('assert.hasAnyKeys', () => { ## hasAllKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has all and only all of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has all and only all of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1227,9 +1227,9 @@ test('assert.hasAllKeys', () => { ## containsAllKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has all of the `keys` provided but may have more keys not listed. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has all of the `keys` provided but may have more keys not listed. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1267,9 +1267,9 @@ test('assert.containsAllKeys', () => { ## doesNotHaveAnyKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has none of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has none of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1299,9 +1299,9 @@ test('assert.doesNotHaveAnyKeys', () => { ## doesNotHaveAllKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` does not have at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` does not have at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1332,9 +1332,9 @@ test('assert.hasAnyKeys', () => { ## hasAnyDeepKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1377,9 +1377,9 @@ test('assert.hasAnyDeepKeys', () => { ## hasAllDeepKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has all and only all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has all and only all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1405,9 +1405,9 @@ test('assert.hasAnyDeepKeys', () => { ## containsAllDeepKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` contains all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` contains all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1439,9 +1439,9 @@ test('assert.containsAllDeepKeys', () => { ## doesNotHaveAnyDeepKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` has none of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` has none of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1473,9 +1473,9 @@ test('assert.doesNotHaveAnyDeepKeys', () => { ## doesNotHaveAllDeepKeys -- **Type:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -Asserts that `object` does not have at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` does not have at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. ```ts import { assert, test } from 'vitest' @@ -1507,14 +1507,14 @@ test('assert.doesNotHaveAllDeepKeys', () => { ## throws -- **Type:** +- **类型:** - `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` - `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` - **Alias:** - `throw` - `Throw` -If `errorLike` is an Error constructor, asserts that `fn` will throw an error that is an instance of `errorLike`. If errorLike is an Error instance, asserts that the error thrown is the same instance as `errorLike`. If `errMsgMatcher` is provided, it also asserts that the error thrown will have a message matching `errMsgMatcher`. +If `errorLike` is an Error constructor, 断言 `fn` will throw an error that is an instance of `errorLike`. If errorLike is an Error instance, 断言 the error thrown is the same instance as `errorLike`. If `errMsgMatcher` is provided, it also 断言 the error thrown will have a message matching `errMsgMatcher`. ```ts import { assert, test } from 'vitest' @@ -1549,10 +1549,10 @@ test('assert.throws', () => { ## doesNotThrow -- **Type:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` -- **Type:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` +- **类型:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` +- **类型:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` -If `errorLike` is an Error constructor, asserts that `fn` will not throw an error that is an instance of `errorLike`. If errorLike is an Error instance, asserts that the error thrown is not the same instance as `errorLike`. If `errMsgMatcher` is provided, it also asserts that the error thrown will not have a message matching `errMsgMatcher`. +If `errorLike` is an Error constructor, 断言 `fn` will not throw an error that is an instance of `errorLike`. If errorLike is an Error instance, 断言 the error thrown is not the same instance as `errorLike`. If `errMsgMatcher` is provided, it also 断言 the error thrown will not have a message matching `errMsgMatcher`. ```ts import { assert, test } from 'vitest' @@ -1571,7 +1571,7 @@ test('assert.doesNotThrow', () => { ## operator -- **Type:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` +- **类型:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` Compare `val1` and `val2` using `operator`. @@ -1585,10 +1585,10 @@ test('assert.operator', () => { ## closeTo -- **Type:** `(actual: number, expected: number, delta: number, message?: string) => void` +- **类型:** `(actual: number, expected: number, delta: number, message?: string) => void` - **Alias:** `approximately` -Asserts that the `actual` is equal `expected`, to within a +/- `delta` range. +断言 the `actual` is equal `expected`, to within a +/- `delta` range. ```ts import { assert, test } from 'vitest' @@ -1600,9 +1600,9 @@ test('assert.closeTo', () => { ## sameMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` have the same members in any order. Uses a strict equality check (===). +断言 `set1` and `set2` have the same members in any order. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1614,9 +1614,9 @@ test('assert.sameMembers', () => { ## notSameMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` don't have the same members in any order. Uses a strict equality check (===). +断言 `set1` and `set2` don't have the same members in any order. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1628,9 +1628,9 @@ test('assert.sameMembers', () => { ## sameDeepMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` have the same members in any order. Uses a deep equality check. +断言 `set1` and `set2` have the same members in any order. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1646,9 +1646,9 @@ test('assert.sameDeepMembers', () => { ## notSameDeepMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` don’t have the same members in any order. Uses a deep equality check. +断言 `set1` and `set2` don’t have the same members in any order. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1664,9 +1664,9 @@ test('assert.sameDeepMembers', () => { ## sameOrderedMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). +断言 `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1678,9 +1678,9 @@ test('assert.sameOrderedMembers', () => { ## notSameOrderedMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). +断言 `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1696,9 +1696,9 @@ test('assert.notSameOrderedMembers', () => { ## sameDeepOrderedMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` have the same members in the same order. Uses a deep equality check. +断言 `set1` and `set2` have the same members in the same order. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1714,9 +1714,9 @@ test('assert.sameDeepOrderedMembers', () => { ## notSameDeepOrderedMembers -- **Type:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` -Asserts that `set1` and `set2` don’t have the same members in the same order. Uses a deep equality check. +断言 `set1` and `set2` don’t have the same members in the same order. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1737,9 +1737,9 @@ test('assert.notSameDeepOrderedMembers', () => { ## includeMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` is included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. +断言 `subset` is included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. ```ts import { assert, test } from 'vitest' @@ -1751,9 +1751,9 @@ test('assert.includeMembers', () => { ## notIncludeMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` isn't included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. +断言 `subset` isn't included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. ```ts import { assert, test } from 'vitest' @@ -1765,9 +1765,9 @@ test('assert.notIncludeMembers', () => { ## includeDeepMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` is included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. +断言 `subset` is included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. ```ts import { assert, test } from 'vitest' @@ -1783,9 +1783,9 @@ test('assert.includeDeepMembers', () => { ## notIncludeDeepMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` isn’t included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. +断言 `subset` isn’t included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. ```ts import { assert, test } from 'vitest' @@ -1801,9 +1801,9 @@ test('assert.notIncludeDeepMembers', () => { ## includeOrderedMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). +断言 `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1815,9 +1815,9 @@ test('assert.includeOrderedMembers', () => { ## notIncludeOrderedMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` isn't included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). +断言 `subset` isn't included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). ```ts import { assert, test } from 'vitest' @@ -1838,9 +1838,9 @@ test('assert.notIncludeOrderedMembers', () => { ## includeDeepOrderedMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a deep equality check. +断言 `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1856,9 +1856,9 @@ test('assert.includeDeepOrderedMembers', () => { ## notIncludeDeepOrderedMembers -- **Type:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` -Asserts that `subset` isn’t included in `superset` in the same order beginning with the first element in superset. Uses a deep equality check. +断言 `subset` isn’t included in `superset` in the same order beginning with the first element in superset. Uses a deep equality check. ```ts import { assert, test } from 'vitest' @@ -1884,9 +1884,9 @@ test('assert.includeDeepOrderedMembers', () => { ## oneOf -- **Type:** `(inList: T, list: T[], message?: string) => void` +- **类型:** `(inList: T, list: T[], message?: string) => void` -Asserts that non-object, non-array value `inList` appears in the flat array `list`. +断言 non-object, non-array value `inList` appears in the flat array `list`. ```ts import { assert, test } from 'vitest' @@ -1898,9 +1898,9 @@ test('assert.oneOf', () => { ## changes -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` changes the `object` of a `property`. +断言 a `modifier` changes the `object` of a `property`. ```ts import { assert, test } from 'vitest' @@ -1916,9 +1916,9 @@ test('assert.changes', () => { ## changesBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` changes the `object` of a `property` by a `change`. +断言 a `modifier` changes the `object` of a `property` by a `change`. ```ts import { assert, test } from 'vitest' @@ -1934,9 +1934,9 @@ test('assert.changesBy', () => { ## doesNotChange -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` does not changes the `object` of a `property`. +断言 a `modifier` does not changes the `object` of a `property`. ```ts import { assert, test } from 'vitest' @@ -1952,9 +1952,9 @@ test('assert.doesNotChange', () => { ## changesButNotBy -- **Type:** `(modifier: Function, object: T, property: string, change:number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change:number, message?: string) => void` -Asserts that a `modifier` does not change the `object` of a `property` or of a `modifier` return value by a `change`. +断言 a `modifier` does not change the `object` of a `property` or of a `modifier` return value by a `change`. ```ts import { assert, test } from 'vitest' @@ -1970,9 +1970,9 @@ test('assert.changesButNotBy', () => { ## increases -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` increases a numeric `object`'s `property`. +断言 a `modifier` increases a numeric `object`'s `property`. ```ts import { assert, test } from 'vitest' @@ -1988,9 +1988,9 @@ test('assert.increases', () => { ## increasesBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` increases a numeric `object`'s `property` or a `modifier` return value by an `change`. +断言 a `modifier` increases a numeric `object`'s `property` or a `modifier` return value by an `change`. ```ts import { assert, test } from 'vitest' @@ -2004,9 +2004,9 @@ test('assert.increasesBy', () => { ## doesNotIncrease -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` does not increases a numeric `object`'s `property`. +断言 a `modifier` does not increases a numeric `object`'s `property`. ```ts import { assert, test } from 'vitest' @@ -2022,9 +2022,9 @@ test('assert.doesNotIncrease', () => { ## increasesButNotBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` does not increases a numeric `object`'s `property` or a `modifier` return value by an `change`. +断言 a `modifier` does not increases a numeric `object`'s `property` or a `modifier` return value by an `change`. ```ts import { assert, test } from 'vitest' @@ -2040,9 +2040,9 @@ test('assert.increasesButNotBy', () => { ## decreases -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` decreases a numeric `object`'s `property`. +断言 a `modifier` decreases a numeric `object`'s `property`. ```ts import { assert, test } from 'vitest' @@ -2058,9 +2058,9 @@ test('assert.decreases', () => { ## decreasesBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` decreases a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 a `modifier` decreases a numeric `object`'s `property` or a `modifier` return value by a `change`. ```ts import { assert, test } from 'vitest' @@ -2076,9 +2076,9 @@ test('assert.decreasesBy', () => { ## doesNotDecrease -- **Type:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -Asserts that a `modifier` dose not decrease a numeric `object`'s `property`. +断言 a `modifier` dose not decrease a numeric `object`'s `property`. ```ts import { assert, test } from 'vitest' @@ -2094,9 +2094,9 @@ test('assert.doesNotDecrease', () => { ## doesNotDecreaseBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. ```ts import { assert, test } from 'vitest' @@ -2112,9 +2112,9 @@ test('assert.doesNotDecreaseBy', () => { ## decreasesButNotBy -- **Type:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -Asserts that a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. ```ts import { assert, test } from 'vitest' @@ -2130,7 +2130,7 @@ test('assert.decreasesButNotBy', () => { ## ifError -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` Asserts if `object` is not a false value, and throws if it is a true value. This is added to allow for chai to be a drop-in replacement for Node’s assert class. @@ -2145,10 +2145,10 @@ test('assert.ifError', () => { ## isExtensible -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `extensible` -Asserts that `object` is extensible (can have new properties added to it). +断言 `object` is extensible (can have new properties added to it). ```ts import { assert, test } from 'vitest' @@ -2160,10 +2160,10 @@ test('assert.isExtensible', () => { ## isNotExtensible -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `notExtensible` -Asserts that `object` is not extensible (can not have new properties added to it). +断言 `object` is not extensible (can not have new properties added to it). ```ts import { assert, test } from 'vitest' @@ -2181,10 +2181,10 @@ test('assert.isNotExtensible', () => { ## isSealed -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `sealed` -Asserts that `object` is sealed (cannot have new properties added to it and its existing properties cannot be removed). +断言 `object` is sealed (cannot have new properties added to it and its existing properties cannot be removed). ```ts import { assert, test } from 'vitest' @@ -2200,10 +2200,10 @@ test('assert.isSealed', () => { ## isNotSealed -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `notSealed` -Asserts that `object` is not sealed (can have new properties added to it and its existing properties can be removed). +断言 `object` is not sealed (can have new properties added to it and its existing properties can be removed). ```ts import { assert, test } from 'vitest' @@ -2215,10 +2215,10 @@ test('assert.isNotSealed', () => { ## isFrozen -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `frozen` -Asserts that object is frozen (cannot have new properties added to it and its existing properties cannot be modified). +断言 object is frozen (cannot have new properties added to it and its existing properties cannot be modified). ```ts import { assert, test } from 'vitest' @@ -2231,10 +2231,10 @@ test('assert.isFrozen', () => { ## isNotFrozen -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `notFrozen` -Asserts that `object` is not frozen (can have new properties added to it and its existing properties can be modified). +断言 `object` is not frozen (can have new properties added to it and its existing properties can be modified). ```ts import { assert, test } from 'vitest' @@ -2246,10 +2246,10 @@ test('assert.isNotFrozen', () => { ## isEmpty -- **Type:** `(target: T, message?: string) => void` +- **类型:** `(target: T, message?: string) => void` - **Alias:** `empty` -Asserts that the `target` does not contain any values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. +断言 the `target` does not contain any values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. ```ts import { assert, test } from 'vitest' @@ -2264,10 +2264,10 @@ test('assert.isEmpty', () => { ## isNotEmpty -- **Type:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` - **Alias:** `notEmpty` -Asserts that the `target` contains values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. +断言 the `target` contains values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. ```ts import { assert, test } from 'vitest' diff --git a/api/expect-typeof.md b/api/expect-typeof.md index 1b23800c..8ac3e967 100644 --- a/api/expect-typeof.md +++ b/api/expect-typeof.md @@ -46,7 +46,7 @@ expectTypeOf().not.toMatchTypeOf() ## toExtend -- **Type:** `(expected: T) => void` +- **类型:** `(expected: T) => void` 这个匹配器用于检查期望类型是否扩展了提供的类型。它与 `toEqual` 不同,更类似于 [expect](/api/expect) 的 `toMatchObject()`。使用这个匹配器,你可以检查一个对象是否"匹配"某个类型。 @@ -60,7 +60,7 @@ expectTypeOf().not.toExtend() ## toMatchObjectType -- **Type:** `() => void` +- **类型:** `() => void` 这个匹配器对对象类型执行严格检查,确保期望的类型与提供的对象类型相匹配。它比 [`toExtend`](#toextend) 更严格,是在处理对象类型时的推荐选择,因为它更有可能捕获到像只读属性这样的问题。 diff --git a/api/expect.md b/api/expect.md index 5b474d1e..f57ff851 100644 --- a/api/expect.md +++ b/api/expect.md @@ -41,7 +41,7 @@ expect(input).toBe(2) // jest API ## assert -- **Type:** `Chai.AssertStatic` +- **类型:** `Chai.AssertStatic` Vitest reexports chai's [`assert` API](https://www.chaijs.com/api/assert/) as `expect.assert` for convenience. You can see the supported methods on the [Assert API page](/api/assert). @@ -332,7 +332,7 @@ test('we don\'t have apples', () => { ## toBeNullable -- **Type:** `() => Awaitable` +- **类型:** `() => Awaitable` `toBeNullable` simply asserts if something is nullable (`null` or `undefined`). diff --git a/config/index.md b/config/index.md index 91a9682c..9acd9040 100644 --- a/config/index.md +++ b/config/index.md @@ -139,7 +139,7 @@ export default defineConfig({ ### name -- **Type:** `string | { label: string, color?: LabelColor }` +- **类型:** `string | { label: string, color?: LabelColor }` 你可以为测试项目或 Vitest 进程指定一个自定义名称,这个名称会在命令行界面(CLI)和用户界面(UI)中显示,同时也能通过 Node.js API 中的 [`project.name`](/advanced/api/test-project#name) 获取。 @@ -624,7 +624,7 @@ jsdom 环境变量导出了等同于当前[JSDOM](https://github.com/jsdom/jsdom ### watchTriggerPatterns 3.2.0 {#watchtriggerpatterns} -- **Type:** `WatcherTriggerPattern[]` +- **类型:** `WatcherTriggerPattern[]` Vitest 依据静态与动态 `import` 语句生成的模块图来决定重新执行哪些测试。但若测试读取文件系统或向代理拉取数据,这些依赖便无法被自动探测。 @@ -1069,7 +1069,7 @@ globalThis.resetBeforeEachTest = true ### provide 2.1.0 {#provide} -- **Type:** `Partial` +- **类型:** `Partial` 使用 `inject` 方法定义可在测试中访问的值。 @@ -1509,7 +1509,7 @@ Vitest 会将所有文件,包括那些被 glob 模式覆盖的文件,计入 ##### coverage.thresholds[glob-pattern].100 2.1.0 {#coverage-thresholds-glob-pattern-100} -- **Type:** `boolean` +- **类型:** `boolean` - **Default:** `false` - **Available for providers:** `'v8' | 'istanbul'` @@ -1847,7 +1847,7 @@ npx vitest --sequence.shuffle --sequence.seed=1000 #### groupOrder 3.2.0 {#grouporder} -- **Type:** `number` +- **类型:** `number` - **Default:** `0` 控制使用多个[项目](/guide/projects) 时该项目运行测试的顺序。 @@ -2172,7 +2172,7 @@ export default defineConfig({ ### onUnhandledError {#onunhandlederror} -- **Type:** `(error: (TestError | Error) & { type: string }) => boolean | void` +- **类型:** `(error: (TestError | Error) & { type: string }) => boolean | void` 自定义处理程序,用于过滤掉不应报告的未处理错误。 如果过滤掉错误,则不会再影响测试结果。 diff --git a/guide/browser/config.md b/guide/browser/config.md index 6908e527..f5830437 100644 --- a/guide/browser/config.md +++ b/guide/browser/config.md @@ -302,7 +302,7 @@ export interface BrowserScript { ## browser.trace -- **Type:** `'on' | 'off' | 'on-first-retry' | 'on-all-retries' | 'retain-on-failure' | object` +- **类型:** `'on' | 'off' | 'on-first-retry' | 'on-all-retries' | 'retain-on-failure' | object` - **CLI:** `--browser.trace=on`, `--browser.trace=retain-on-failure` - **Default:** `'off'` @@ -346,7 +346,7 @@ This option is supported only by the [**playwright**](/guide/browser/playwright) ## browser.trackUnhandledErrors -- **Type:** `boolean` +- **类型:** `boolean` - **Default:** `true` 启用对未捕获错误和异常的跟踪,以便 Vitest 报告。 @@ -357,7 +357,7 @@ This option is supported only by the [**playwright**](/guide/browser/playwright) ## browser.expect -- **Type:** `ExpectOptions` +- **类型:** `ExpectOptions` ### browser.expect.toMatchScreenshot @@ -395,7 +395,7 @@ export default defineConfig({ #### browser.expect.toMatchScreenshot.resolveScreenshotPath -- **Type:** `(data: PathResolveData) => string` +- **类型:** `(data: PathResolveData) => string` - **Default output:** `` `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` `` 一个用于自定义参考截图存储位置的函数。该函数接收一个包含以下属性的对象: @@ -465,7 +465,7 @@ resolveScreenshotPath: ({ arg, browserName, ext, root, testFileName }) => #### browser.expect.toMatchScreenshot.resolveDiffPath -- **Type:** `(data: PathResolveData) => string` +- **类型:** `(data: PathResolveData) => string` - **Default output:** `` `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}` `` 一个用于自定义截图比较失败时差异图像存储位置的函数。它接收与 [`resolveScreenshotPath`](#browser-expect-tomatchscreenshot-resolvescreenshotpath) 相同的数据对象。 diff --git a/guide/browser/locators.md b/guide/browser/locators.md index 3640effa..7f6699da 100644 --- a/guide/browser/locators.md +++ b/guide/browser/locators.md @@ -499,7 +499,7 @@ This methods narrows down the locator according to the options, such as filterin ### has -- **Type:** `Locator` +- **类型:** `Locator` This options narrows down the selector to match elements that contain other elements matching provided locator. For example, with this HTML: @@ -542,7 +542,7 @@ page.getByRole('article') ### hasNot -- **Type:** `Locator` +- **类型:** `Locator` This option narrows down the selector to match elements that do not contain other elements matching provided locator. For example, with this HTML: @@ -570,7 +570,7 @@ Note that provided locator is queried against the parent, not the document root, ### hasText -- **Type:** `string | RegExp` +- **类型:** `string | RegExp` This options narrows down the selector to only match elements that contain provided text somewhere inside. When the `string` is passed, matching is case-insensitive and searches for a substring. @@ -592,7 +592,7 @@ page.getByRole('article').filter({ hasText: 'Vite' }) // ✅ ### hasNotText -- **Type:** `string | RegExp` +- **类型:** `string | RegExp` This options narrows down the selector to only match elements that do not contain provided text somewhere inside. When the `string` is passed, matching is case-insensitive and searches for a substring. From fc7dfbd8820710a0149739bbdbf8d51e06e8b3d8 Mon Sep 17 00:00:00 2001 From: noise Date: Tue, 11 Nov 2025 22:58:59 +0800 Subject: [PATCH 2/8] docs: update /guide/assert --- api/assert.md | 216 +++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/api/assert.md b/api/assert.md index bbb80112..a5bc8989 100644 --- a/api/assert.md +++ b/api/assert.md @@ -111,7 +111,7 @@ test('assert.strictEqual', () => { - **类型:** `(actual: T, expected: T, message?: string) => void` -断言 `actual` 和 `expected` 深度相等。 +断言 `actual` 深度等于 `expected` 。 ```ts import { assert, test } from 'vitest' @@ -125,7 +125,7 @@ test('assert.deepEqual', () => { - **类型:** `(actual: T, expected: T, message?: string) => void` -断言 `actual` 和 `expected` 不深度相等。 +断言 `actual` 不深度等于 `expected` 。 ```ts import { assert, test } from 'vitest' @@ -153,7 +153,7 @@ test('assert.isAbove', () => { - **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` -断言 `valueToCheck` 大于等于 (>=) `valueToBeAtLeast`。 +断言 `valueToCheck` 大于或等于 (>=) `valueToBeAtLeast`。 ```ts import { assert, test } from 'vitest' @@ -182,7 +182,7 @@ test('assert.isBelow', () => { - **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` -断言 `valueToCheck` 小于等于 (<=) `valueToBeAtMost`。 +断言 `valueToCheck` 小于或等于 (<=) `valueToBeAtMost`。 ```ts import { assert, test } from 'vitest' @@ -325,7 +325,7 @@ test('assert.isNotNaN', () => { - **类型:** `(value: T, message?: string) => asserts value is NonNullable` -断言 `value` 既不是 null 也不是 undefined. +断言 `value` 既不是 null 也不是 undefined。 ```ts import { assert, test } from 'vitest' @@ -341,7 +341,7 @@ test('assert.exists', () => { - **类型:** `(value: T, message?: string) => asserts value is null | undefined` -断言 `value` 要么是 null 要么是 undefined. +断言 `value` 是 null 或 undefined。 ```ts import { assert, test } from 'vitest' @@ -359,7 +359,7 @@ test('assert.notExists', () => { - **类型:** `(value: T, message?: string) => asserts value is undefined` -断言 `value` 是 undefined. +断言 `value` 是 undefined。 ```ts import { assert, test } from 'vitest' @@ -375,7 +375,7 @@ test('assert.isUndefined', () => { - **类型:** `(value: T, message?: string) => asserts value is Exclude` -断言 `value` 不是 undefined. +断言 `value` 不是 undefined。 ```ts import { assert, test } from 'vitest' @@ -390,8 +390,8 @@ test('assert.isDefined', () => { ## isFunction - **类型:** `(value: T, message?: string) => void` -- **Alias:** `isCallable` - 断言 `value` 是一个 function. +- **别名:** `isCallable` + 断言 `value` 是一个函数。 ```ts import { assert, test } from 'vitest' @@ -408,9 +408,9 @@ test('assert.isFunction', () => { ## isNotFunction - **类型:** `(value: T, message?: string) => void` -- **Alias:** `isNotCallable` +- **别名:** `isNotCallable` -断言 `value` 不是一个 function. +断言 `value` 不是一个函数。 ```ts import { assert, test } from 'vitest' @@ -426,7 +426,7 @@ test('assert.isNotFunction', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 是一个类型为 Object (如 Object.prototype.toString)。 该断言不匹配子类对象。 +断言 `value` 是一个类型为 'Object' 的对象 (由 Object.prototype.toString 确定)。 此断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' @@ -442,7 +442,7 @@ test('assert.isObject', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 不是一个 (如 Object.prototype.toString)。 该断言不匹配子类对象。 +断言 `value` 不是一个类型为 'Object' 的对象 (如 Object.prototype.toString 确定)。 该断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' @@ -522,7 +522,7 @@ test('assert.isNotString', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 是一个数值。 +断言 `value` 是一个数字。 ```ts import { assert, test } from 'vitest' @@ -538,7 +538,7 @@ test('assert.isNumber', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 不是一个数值。 +断言 `value` 不是一个数字。 ```ts import { assert, test } from 'vitest' @@ -554,7 +554,7 @@ test('assert.isNotNumber', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 是一个有限数值 (不是 NaN, Infinity)。 +断言 `value` 是一个有限数字。(不是 NaN, Infinity)。 ```ts import { assert, test } from 'vitest' @@ -692,7 +692,7 @@ test('assert.instanceOf', () => { - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -断言 `haystack` 包含 `needle`。可用于以下场景:数组中包含某个值、字符串中包含某些字符串、对象中包含属性子集。 +断言 `haystack` 包含 `needle`。可以用来断言数组中是否包含一个值、字符串中是否包含一个子字符串、或者对象中是否包含一组属性。 ```ts import { assert, test } from 'vitest' @@ -716,7 +716,7 @@ test('assert.include', () => { - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -断言 `haystack` 不包含 `needle`。可用于以下场景:数组中包含某个值、字符串中包含某些字符串、对象中包含属性子集。 +断言 `haystack` 不包含 `needle`。可以用来断言数组中是否不包含一个值、字符串中是否不包含一个子字符串、或者对象中是否不包含一组属性。 ```ts import { assert, test } from 'vitest' @@ -739,7 +739,7 @@ test('assert.notInclude', () => { - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -断言 `haystack` includes `needle`。 可用于断言数组是否包含某个值,或对象是否包含属性子集。可用于深度比较。 +断言 `haystack` 包含 `needle`。可以用来断言数组中是否包含一个值或对象中是否包含一组属性。使用深度相等。 ```ts import { assert, test } from 'vitest' @@ -760,7 +760,7 @@ test('assert.deepInclude', () => { - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -断言 `haystack` 不包含 `needle`。可用于断言数组是否包含某个值,或对象是否包含属性子集。可用于深度比较。 +断言 `haystack` 不包含 `needle`。可以用来断言数组中是否不包含一个值或对象中是否不包含一组属性。使用深度相等。 ```ts import { assert, test } from 'vitest' @@ -778,7 +778,7 @@ test('assert.notDeepInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` 包含 `needle`。 可以用来断言对象中是否包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -793,7 +793,7 @@ test('assert.nestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` does not include `needle`. Can be used to assert the inclusion of a subset of properties in an object. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -808,7 +808,7 @@ test('assert.nestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` 包含 `needle`可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -826,7 +826,7 @@ test('assert.deepNestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while checking for deep equality. Enables the use of dot- and bracket-notation for referencing nested properties. ‘[]’ and ‘.’ in property names can be escaped using double backslashes. +断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -844,7 +844,7 @@ test('assert.notDeepNestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties. +断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性。 ```ts import { assert, test } from 'vitest' @@ -858,7 +858,7 @@ test('assert.ownInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties. +断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性 ```ts import { assert, test } from 'vitest' @@ -879,7 +879,7 @@ test('assert.notOwnInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` includes `needle`. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties and checking for deep equality. +断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性并检查深度相等性。 ```ts import { assert, test } from 'vitest' @@ -893,7 +893,7 @@ test('assert.deepOwnInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` not includes `needle`. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties and checking for deep equality. +断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 ```ts import { assert, test } from 'vitest' @@ -907,7 +907,7 @@ test('assert.notDeepOwnInclude', () => { - **类型:** `(value: string, regexp: RegExp, message?: string) => void` -断言 `value` matches the regular expression `regexp`. +断言 `value` 匹配正则表达式 `regexp`。 ```ts import { assert, test } from 'vitest' @@ -921,7 +921,7 @@ test('assert.match', () => { - **类型:** `(value: string, regexp: RegExp, message?: string) => void` -断言 `value` does not matches the regular expression `regexp`. +断言 `value` 不匹配正则表达式 `regexp`。 ```ts import { assert, test } from 'vitest' @@ -935,7 +935,7 @@ test('assert.notMatch', () => { - **类型:** `(object: T, property: string, message?: string) => void` -断言 `object` has a direct or inherited property named by `property` +断言 `object` 具有由 `property` 指定的直接或继承属性。 ```ts import { assert, test } from 'vitest' @@ -950,7 +950,7 @@ test('assert.property', () => { - **类型:** `(object: T, property: string, message?: string) => void` -断言 `object` does not have a direct or inherited property named by `property` +断言 `object` 没有由 `property` 指定的直接或继承属性。 ```ts import { assert, test } from 'vitest' @@ -964,7 +964,7 @@ test('assert.notProperty', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). +断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 ```ts import { assert, test } from 'vitest' @@ -978,7 +978,7 @@ test('assert.notPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a strict equality check (===). +断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 ```ts import { assert, test } from 'vitest' @@ -993,7 +993,7 @@ test('assert.notPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` has a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. +断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1009,7 +1009,7 @@ test('assert.deepPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` does not have a direct or inherited property named by `property` with a value given by `value`. Uses a deep equality check. +断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1031,7 +1031,7 @@ test('assert.deepPropertyVal', () => { - **类型:** `(object: T, property: string, message?: string) => void` -断言 `object` has a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. +断言 `object` 具有由 `property` 指定的直接或继承属性,它可以是一个字符串,使用点和括号表示法来引用嵌套的引用。 ```ts import { assert, test } from 'vitest' @@ -1045,7 +1045,7 @@ test('assert.deepPropertyVal', () => { - **类型:** `(object: T, property: string, message?: string) => void` -断言 `object` does not have a direct or inherited property named by `property`, which can be a string using dot- and bracket-notation for nested reference. +断言 `object` 没有由 `property` 指定的属性,它可以是一个字符串,使用点和括号表示法来引用嵌套的引用。该属性不能存在于对象上,也不能存在于其原型链中的任何地方。 ```ts import { assert, test } from 'vitest' @@ -1059,7 +1059,7 @@ test('assert.deepPropertyVal', () => { - **类型:** `(object: T, property: string, value: any, message?: string) => void` -断言 `object` has a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). +断言 `object` 具有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用严格相等检查 (===)。 ```ts import { assert, test } from 'vitest' @@ -1073,7 +1073,7 @@ test('assert.nestedPropertyVal', () => { - **类型:** `(object: T, property: string, value: any, message?: string) => void` -断言 `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a strict equality check (===). +断言 `object` 没有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用严格相等检查 (===)。 ```ts import { assert, test } from 'vitest' @@ -1096,7 +1096,7 @@ test('assert.notNestedPropertyVal', () => { - **类型:** `(object: T, property: string, value: any, message?: string) => void` -断言 `object` has a property named by `property` with a value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check (===). +断言 `object` 具有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1119,7 +1119,7 @@ test('assert.notNestedPropertyVal', () => { - **类型:** `(object: T, property: string, value: any, message?: string) => void` -断言 `object` does not have a property named by `property` with value given by `value`. `property` can use dot- and bracket-notation for nested reference. Uses a deep equality check. +断言 `object` 没有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1147,7 +1147,7 @@ test('assert.notDeepNestedPropertyVal', () => { - **类型:** `(object: T, length: number, message?: string) => void` -断言 `object` has a `length` or `size` with the expected value. +断言 `object` 具有预期的 `length` 或 `size` 值。 ```ts import { assert, test } from 'vitest' @@ -1172,7 +1172,7 @@ test('assert.lengthOf', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 至少拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1201,7 +1201,7 @@ test('assert.hasAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has all and only all of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 拥有且仅拥有所有提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1229,7 +1229,7 @@ test('assert.hasAllKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has all of the `keys` provided but may have more keys not listed. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 拥有所有提供的 `keys`,但可能还有更多未列出的键。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1269,7 +1269,7 @@ test('assert.containsAllKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has none of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 不拥有任何提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1301,7 +1301,7 @@ test('assert.doesNotHaveAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` does not have at least one of the `keys` provided. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 至少不拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1334,7 +1334,7 @@ test('assert.hasAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 至少拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1379,7 +1379,7 @@ test('assert.hasAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has all and only all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 拥有且仅拥有所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1407,7 +1407,7 @@ test('assert.hasAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` contains all of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 包含所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1441,7 +1441,7 @@ test('assert.containsAllDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` has none of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 不拥有任何提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1475,7 +1475,7 @@ test('assert.doesNotHaveAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` does not have at least one of the `keys` provided. Since Sets and Maps can have objects as keys you can use this assertion to perform a deep comparison. You can also provide a single object instead of a keys array and its keys will be used as the expected set of keys. +断言 `object` 至少不拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1510,11 +1510,11 @@ test('assert.doesNotHaveAllDeepKeys', () => { - **类型:** - `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` - `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` -- **Alias:** +- **别名:** - `throw` - `Throw` -If `errorLike` is an Error constructor, 断言 `fn` will throw an error that is an instance of `errorLike`. If errorLike is an Error instance, 断言 the error thrown is the same instance as `errorLike`. If `errMsgMatcher` is provided, it also 断言 the error thrown will have a message matching `errMsgMatcher`. +如果 `errorLike` 是一个 Error 构造函数,则断言 `fn` 将抛出一个 errorLike 实例的错误。如果 `errorLike` 是一个 Error 实例,则断言抛出的错误与 `errorLike` 是同一个实例。如果提供了 `errMsgMatcher`,它还断言抛出的错误将具有与 `errMsgMatcher` 相匹配的消息。 ```ts import { assert, test } from 'vitest' @@ -1552,7 +1552,7 @@ test('assert.throws', () => { - **类型:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` - **类型:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` -If `errorLike` is an Error constructor, 断言 `fn` will not throw an error that is an instance of `errorLike`. If errorLike is an Error instance, 断言 the error thrown is not the same instance as `errorLike`. If `errMsgMatcher` is provided, it also 断言 the error thrown will not have a message matching `errMsgMatcher`. +如果 `errorLike` 是一个 Error 构造函数,则断言 `fn` 不会 抛出一个 errorLike 实例的错误。如果 `errorLike` 是一个 Error 实例,则断言抛出的错误不是 与 errorLike 是同一个实例。如果提供了 `errMsgMatcher`,它还断言抛出的错误不会 具有与 `errMsgMatcher` 相匹配的消息。 ```ts import { assert, test } from 'vitest' @@ -1573,7 +1573,7 @@ test('assert.doesNotThrow', () => { - **类型:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` -Compare `val1` and `val2` using `operator`. +使用 `operator` 比较 `val1` 和 `val2`。 ```ts import { assert, test } from 'vitest' @@ -1586,9 +1586,9 @@ test('assert.operator', () => { ## closeTo - **类型:** `(actual: number, expected: number, delta: number, message?: string) => void` -- **Alias:** `approximately` +- **别名:** `approximately` -断言 the `actual` is equal `expected`, to within a +/- `delta` range. +断言 `actual` 导出 `expected`,误差范围控制在 +/- `delta` 内。 ```ts import { assert, test } from 'vitest' @@ -1602,7 +1602,7 @@ test('assert.closeTo', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` have the same members in any order. Uses a strict equality check (===). +断言 `set1` 和 `set2` 具有相同的成员,但顺序可以不同。使用严格相等检查 (===)。 ```ts import { assert, test } from 'vitest' @@ -1616,7 +1616,7 @@ test('assert.sameMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` don't have the same members in any order. Uses a strict equality check (===). +断言 `set1` 和 `set2` 不具有相同的成员,但顺序可以不同。使用严格相等检查 (===)。 ```ts import { assert, test } from 'vitest' @@ -1630,7 +1630,7 @@ test('assert.sameMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` have the same members in any order. Uses a deep equality check. +断言 `set1` 和 `set2` 具有相同的成员,但顺序可以不同。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1648,7 +1648,7 @@ test('assert.sameDeepMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` don’t have the same members in any order. Uses a deep equality check. +断言 `set1` 和 `set2` 不具有相同的成员,但顺序可以不同。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1666,7 +1666,7 @@ test('assert.sameDeepMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). +断言 `set1` 和 `set2` 具有相同的成员,并且顺序也相同。使用严格相等检查 (===)。 ```ts import { assert, test } from 'vitest' @@ -1680,7 +1680,7 @@ test('assert.sameOrderedMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` have the same members in the same order. Uses a strict equality check (===). +断言 `set1` 和 `set2` 的成员不相同或顺序不同。使用严格相等比较 (===)。 ```ts import { assert, test } from 'vitest' @@ -1698,7 +1698,7 @@ test('assert.notSameOrderedMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` have the same members in the same order. Uses a deep equality check. +断言 `set1` 和 `set2` 的成员相同且顺序相同。使用深度相等比较。 ```ts import { assert, test } from 'vitest' @@ -1716,7 +1716,7 @@ test('assert.sameDeepOrderedMembers', () => { - **类型:** `(set1: T[], set2: T[], message?: string) => void` -断言 `set1` and `set2` don’t have the same members in the same order. Uses a deep equality check. +断言 `set1` 和 `set2` 的成员不相同或顺序不同。使用深度相等比较。 ```ts import { assert, test } from 'vitest' @@ -1739,7 +1739,7 @@ test('assert.notSameDeepOrderedMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` is included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. +断言 `subset` 被包含在 `superset` 中,顺序可以不同。使用严格相等比较 (===)。忽略重复项。 ```ts import { assert, test } from 'vitest' @@ -1753,7 +1753,7 @@ test('assert.includeMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` isn't included in `superset` in any order. Uses a strict equality check (===). Duplicates are ignored. +断言 `subset` 未被包含在 `superset` 中,顺序可以不同。使用严格相等比较 (===)。忽略重复项。 ```ts import { assert, test } from 'vitest' @@ -1767,7 +1767,7 @@ test('assert.notIncludeMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` is included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. +断言 `subset` 被包含在 `superset` 中,顺序可以不同。使用深度相等比较。忽略重复项。 ```ts import { assert, test } from 'vitest' @@ -1785,7 +1785,7 @@ test('assert.includeDeepMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` isn’t included in `superset` in any order. Uses a deep equality check. Duplicates are ignored. +断言 `subset` 未被包含在 `superset` 中,顺序可以不同。使用深度相等比较。忽略重复项。 ```ts import { assert, test } from 'vitest' @@ -1803,7 +1803,7 @@ test('assert.notIncludeDeepMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). +断言 `subset` 被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用严格相等比较 (===)。 ```ts import { assert, test } from 'vitest' @@ -1817,7 +1817,7 @@ test('assert.includeOrderedMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` isn't included in `superset` in the same order beginning with the first element in `superset`. Uses a strict equality check (===). +断言 `subset` 未被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用严格相等比较 (===)。 ```ts import { assert, test } from 'vitest' @@ -1840,7 +1840,7 @@ test('assert.notIncludeOrderedMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` is included in `superset` in the same order beginning with the first element in `superset`. Uses a deep equality check. +断言 `subset` 被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用深度相等比较。 ```ts import { assert, test } from 'vitest' @@ -1858,7 +1858,7 @@ test('assert.includeDeepOrderedMembers', () => { - **类型:** `(superset: T[], subset: T[], message?: string) => void` -断言 `subset` isn’t included in `superset` in the same order beginning with the first element in superset. Uses a deep equality check. +断言 `subset` 未被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用深度相等比较。 ```ts import { assert, test } from 'vitest' @@ -1886,7 +1886,7 @@ test('assert.includeDeepOrderedMembers', () => { - **类型:** `(inList: T, list: T[], message?: string) => void` -断言 non-object, non-array value `inList` appears in the flat array `list`. +断言非对象、非数组值 `inList` 出现在扁平数组 list 中。 ```ts import { assert, test } from 'vitest' @@ -1900,7 +1900,7 @@ test('assert.oneOf', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` changes the `object` of a `property`. +断言 `函数` 用于修改 `property` 所属 `object`。 ```ts import { assert, test } from 'vitest' @@ -1918,7 +1918,7 @@ test('assert.changes', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` changes the `object` of a `property` by a `change`. +断言 `函数` 通过 `change` 修改 `property` 所属的 `object`。 ```ts import { assert, test } from 'vitest' @@ -1936,7 +1936,7 @@ test('assert.changesBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` does not changes the `object` of a `property`. +断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的 `object`。 ```ts import { assert, test } from 'vitest' @@ -1954,7 +1954,7 @@ test('assert.doesNotChange', () => { - **类型:** `(modifier: Function, object: T, property: string, change:number, message?: string) => void` -断言 a `modifier` does not change the `object` of a `property` or of a `modifier` return value by a `change`. +断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的所属对象。 ```ts import { assert, test } from 'vitest' @@ -1972,7 +1972,7 @@ test('assert.changesButNotBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` increases a numeric `object`'s `property`. +断言 `函数` 会增加数值类型对象属性。 ```ts import { assert, test } from 'vitest' @@ -1990,7 +1990,7 @@ test('assert.increases', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` increases a numeric `object`'s `property` or a `modifier` return value by an `change`. +断言 `函数` 会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2006,7 +2006,7 @@ test('assert.increasesBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` does not increases a numeric `object`'s `property`. +断言 `函数` 不会增加数值类型对象属性。 ```ts import { assert, test } from 'vitest' @@ -2024,7 +2024,7 @@ test('assert.doesNotIncrease', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` does not increases a numeric `object`'s `property` or a `modifier` return value by an `change`. +断言 `函数` 不会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2042,7 +2042,7 @@ test('assert.increasesButNotBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` decreases a numeric `object`'s `property`. +断言 `函数` 不会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2060,7 +2060,7 @@ test('assert.decreases', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` decreases a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 `函数` 会通过 `change` 减少数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2078,7 +2078,7 @@ test('assert.decreasesBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 a `modifier` dose not decrease a numeric `object`'s `property`. +断言 `函数` 不会减少数值类型对象属性。 ```ts import { assert, test } from 'vitest' @@ -2096,7 +2096,7 @@ test('assert.doesNotDecrease', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 `函数` 不会通过 `change` 减少数值类型对象属性或 `函数`返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2114,7 +2114,7 @@ test('assert.doesNotDecreaseBy', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 a `modifier` does not decrease a numeric `object`'s `property` or a `modifier` return value by a `change`. +断言 `函数` 不会通过 change 减少数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' @@ -2132,23 +2132,23 @@ test('assert.decreasesButNotBy', () => { - **类型:** `(object: T, message?: string) => void` -Asserts if `object` is not a false value, and throws if it is a true value. This is added to allow for chai to be a drop-in replacement for Node’s assert class. +断言 `object` 是否为假值,如果它是真值则抛出错误。这是为了允许 chai 作为 Node 的 assert 类的一个直接替代品。 ```ts import { assert, test } from 'vitest' test('assert.ifError', () => { const err = new Error('I am a custom error') - assert.ifError(err) // Rethrows err! + assert.ifError(err) // 重新抛出错误! }) ``` ## isExtensible - **类型:** `(object: T, message?: string) => void` -- **Alias:** `extensible` +- **别名:** `extensible` -断言 `object` is extensible (can have new properties added to it). +断言 `object` 是可扩展的(可以向其添加新的属性)。 ```ts import { assert, test } from 'vitest' @@ -2161,9 +2161,9 @@ test('assert.isExtensible', () => { ## isNotExtensible - **类型:** `(object: T, message?: string) => void` -- **Alias:** `notExtensible` +- **别名:** `notExtensible` -断言 `object` is not extensible (can not have new properties added to it). +断言 `object` 是不可扩展的 (不能添加新属性)。 ```ts import { assert, test } from 'vitest' @@ -2182,9 +2182,9 @@ test('assert.isNotExtensible', () => { ## isSealed - **类型:** `(object: T, message?: string) => void` -- **Alias:** `sealed` +- **别名:** `sealed` -断言 `object` is sealed (cannot have new properties added to it and its existing properties cannot be removed). +断言 `object` 是密封的(不能向其添加新的属性,也不能删除其现有属性)。 ```ts import { assert, test } from 'vitest' @@ -2201,9 +2201,9 @@ test('assert.isSealed', () => { ## isNotSealed - **类型:** `(object: T, message?: string) => void` -- **Alias:** `notSealed` +- **别名:** `notSealed` -断言 `object` is not sealed (can have new properties added to it and its existing properties can be removed). +断言 `object` 未被密封(可以添加新属性,并且可以删除其现有属性)。 ```ts import { assert, test } from 'vitest' @@ -2216,9 +2216,9 @@ test('assert.isNotSealed', () => { ## isFrozen - **类型:** `(object: T, message?: string) => void` -- **Alias:** `frozen` +- **别名:** `frozen` -断言 object is frozen (cannot have new properties added to it and its existing properties cannot be modified). +断言 `object` 是冻结的(不能向其添加新的属性,也不能修改其现有属性)。 ```ts import { assert, test } from 'vitest' @@ -2232,9 +2232,9 @@ test('assert.isFrozen', () => { ## isNotFrozen - **类型:** `(object: T, message?: string) => void` -- **Alias:** `notFrozen` +- **别名:** `notFrozen` -断言 `object` is not frozen (can have new properties added to it and its existing properties can be modified). +断言 `object` 未被冻结(可以向其添加新属性,并且可以修改其现有属性)。 ```ts import { assert, test } from 'vitest' @@ -2247,9 +2247,9 @@ test('assert.isNotFrozen', () => { ## isEmpty - **类型:** `(target: T, message?: string) => void` -- **Alias:** `empty` +- **别名:** `empty` -断言 the `target` does not contain any values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. +断言 `target` 不包含任何值。对于数组和字符串,它检查 length 属性。对于 Map 和 Set 实例,它检查 size 属性。对于非函数对象,它获取自身可枚举字符串键的数量。 ```ts import { assert, test } from 'vitest' @@ -2265,9 +2265,9 @@ test('assert.isEmpty', () => { ## isNotEmpty - **类型:** `(object: T, message?: string) => void` -- **Alias:** `notEmpty` +- **别名:** `notEmpty` -断言 the `target` contains values. For arrays and strings, it checks the length property. For Map and Set instances, it checks the size property. For non-function objects, it gets the count of its own enumerable string keys. +断言 `target` 包含值。对于数组和字符串,它检查 length 属性。对于 Map 和 Set 实例,它检查 size 属性。对于非函数对象,它获取自身可枚举字符串键的数量。 ```ts import { assert, test } from 'vitest' From 312a3c204017a15dd77c9aaf53d758ee79a721bc Mon Sep 17 00:00:00 2001 From: noise Date: Tue, 11 Nov 2025 23:06:32 +0800 Subject: [PATCH 3/8] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9`=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B`=E7=9A=84=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/assert.md | 270 +++++++++++++++++++++++++------------------------- api/expect.md | 4 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/api/assert.md b/api/assert.md index a5bc8989..eb755b56 100644 --- a/api/assert.md +++ b/api/assert.md @@ -4,7 +4,7 @@ Vitest 从 [`chai`](https://www.chaijs.com/api/assert/) 重新导出了 `assert` ## assert -- **类型:** `(expression: any, message?: string) => asserts expression` +- **类型:** `(expression: any, message?: string) => asserts expression` 断言给定的 `expression` 是 true,否则断言失败。 @@ -18,7 +18,7 @@ test('assert', () => { ## fail -- **类型:** +- **类型:** - `(message?: string) => never` - `(actual: T, expected: T, message?: string, operator?: string) => never` @@ -35,7 +35,7 @@ test('assert.fail', () => { ## isOk -- **类型:** `(value: T, message?: string) => asserts value` +- **类型:** `(value: T, message?: string) => asserts value` - **Alias** `ok` 断言给定的 `value` 是 true。 @@ -51,7 +51,7 @@ test('assert.isOk', () => { ## isNotOk -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` - **Alias** `notOk` 断言给定的 `value` 是 false。 @@ -67,7 +67,7 @@ test('assert.isNotOk', () => { ## equal -- **类型:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` 断言 `actual` 和 `expected` 非严格相等 (==)。 @@ -81,7 +81,7 @@ test('assert.equal', () => { ## notEqual -- **类型:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` 断言 `actual` 和 `expected` 非严格不等(!=). @@ -95,7 +95,7 @@ test('assert.equal', () => { ## strictEqual -- **类型:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` 断言 `actual` 和 `expected` 严格相等 (===)。 @@ -109,7 +109,7 @@ test('assert.strictEqual', () => { ## deepEqual -- **类型:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` 断言 `actual` 深度等于 `expected` 。 @@ -123,7 +123,7 @@ test('assert.deepEqual', () => { ## notDeepEqual -- **类型:** `(actual: T, expected: T, message?: string) => void` +- **类型:** `(actual: T, expected: T, message?: string) => void` 断言 `actual` 不深度等于 `expected` 。 @@ -137,7 +137,7 @@ test('assert.notDeepEqual', () => { ## isAbove -- **类型:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` 断言 `valueToCheck` 严格大于 (>) `valueToBeAbove`。 @@ -151,7 +151,7 @@ test('assert.isAbove', () => { ## isAtLeast -- **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` 断言 `valueToCheck` 大于或等于 (>=) `valueToBeAtLeast`。 @@ -166,7 +166,7 @@ test('assert.isAtLeast', () => { ## isBelow -- **类型:** `(valueToCheck: number, valueToBeBelow: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeBelow: number, message?: string) => void` 断言 `valueToCheck` 严格小于 (<) `valueToBeBelow`。 @@ -180,7 +180,7 @@ test('assert.isBelow', () => { ## isAtMost -- **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` +- **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` 断言 `valueToCheck` 小于或等于 (<=) `valueToBeAtMost`。 @@ -195,7 +195,7 @@ test('assert.isAtMost', () => { ## isTrue -- **类型:** `(value: T, message?: string) => asserts value is true` +- **类型:** `(value: T, message?: string) => asserts value is true` 断言 `value` 是 true。 @@ -211,7 +211,7 @@ test('assert.isTrue', () => { ## isNotTrue -- **类型:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` 断言 `value` 不是 true。 @@ -227,7 +227,7 @@ test('assert.isNotTrue', () => { ## isFalse -- **类型:** `(value: T, message?: string) => asserts value is false` +- **类型:** `(value: T, message?: string) => asserts value is false` 断言 `value` 是 false。 @@ -243,7 +243,7 @@ test('assert.isFalse', () => { ## isNotFalse -- **类型:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` 断言 `value` 不是 false。 @@ -259,7 +259,7 @@ test('assert.isNotFalse', () => { ## isNull -- **类型:** `(value: T, message?: string) => asserts value is null` +- **类型:** `(value: T, message?: string) => asserts value is null` 断言 `value` 是 null。 @@ -275,7 +275,7 @@ test('assert.isNull', () => { ## isNotNull -- **类型:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` 断言 `value` 不是 null。 @@ -291,7 +291,7 @@ test('assert.isNotNull', () => { ## isNaN -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是 NaN。 @@ -307,7 +307,7 @@ test('assert.isNaN', () => { ## isNotNaN -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是 NaN。 @@ -323,7 +323,7 @@ test('assert.isNotNaN', () => { ## exists -- **类型:** `(value: T, message?: string) => asserts value is NonNullable` +- **类型:** `(value: T, message?: string) => asserts value is NonNullable` 断言 `value` 既不是 null 也不是 undefined。 @@ -339,7 +339,7 @@ test('assert.exists', () => { ## notExists -- **类型:** `(value: T, message?: string) => asserts value is null | undefined` +- **类型:** `(value: T, message?: string) => asserts value is null | undefined` 断言 `value` 是 null 或 undefined。 @@ -357,7 +357,7 @@ test('assert.notExists', () => { ## isUndefined -- **类型:** `(value: T, message?: string) => asserts value is undefined` +- **类型:** `(value: T, message?: string) => asserts value is undefined` 断言 `value` 是 undefined。 @@ -373,7 +373,7 @@ test('assert.isUndefined', () => { ## isDefined -- **类型:** `(value: T, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, message?: string) => asserts value is Exclude` 断言 `value` 不是 undefined。 @@ -389,8 +389,8 @@ test('assert.isDefined', () => { ## isFunction -- **类型:** `(value: T, message?: string) => void` -- **别名:** `isCallable` +- **类型:** `(value: T, message?: string) => void` +- **别名:** `isCallable` 断言 `value` 是一个函数。 ```ts @@ -407,8 +407,8 @@ test('assert.isFunction', () => { ## isNotFunction -- **类型:** `(value: T, message?: string) => void` -- **别名:** `isNotCallable` +- **类型:** `(value: T, message?: string) => void` +- **别名:** `isNotCallable` 断言 `value` 不是一个函数。 @@ -424,7 +424,7 @@ test('assert.isNotFunction', () => { ## isObject -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个类型为 'Object' 的对象 (由 Object.prototype.toString 确定)。 此断言不匹配子类对象。 @@ -440,7 +440,7 @@ test('assert.isObject', () => { ## isNotObject -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是一个类型为 'Object' 的对象 (如 Object.prototype.toString 确定)。 该断言不匹配子类对象。 @@ -456,7 +456,7 @@ test('assert.isNotObject', () => { ## isArray -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个数组。 @@ -472,7 +472,7 @@ test('assert.isArray', () => { ## isNotArray -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是一个数组。 @@ -488,7 +488,7 @@ test('assert.isNotArray', () => { ## isString -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个字符串。 @@ -504,7 +504,7 @@ test('assert.isString', () => { ## isNotString -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是一个字符串。 @@ -520,7 +520,7 @@ test('assert.isNotString', () => { ## isNumber -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个数字。 @@ -536,7 +536,7 @@ test('assert.isNumber', () => { ## isNotNumber -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是一个数字。 @@ -552,7 +552,7 @@ test('assert.isNotNumber', () => { ## isFinite -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个有限数字。(不是 NaN, Infinity)。 @@ -568,7 +568,7 @@ test('assert.isFinite', () => { ## isBoolean -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 是一个布尔值。 @@ -584,7 +584,7 @@ test('assert.isBoolean', () => { ## isNotBoolean -- **类型:** `(value: T, message?: string) => void` +- **类型:** `(value: T, message?: string) => void` 断言 `value` 不是一个布尔值。 @@ -600,7 +600,7 @@ test('assert.isBoolean', () => { ## typeOf -- **类型:** `(value: T, name: string, message?: string) => void` +- **类型:** `(value: T, name: string, message?: string) => void` 断言 `value` 的类型是 `name`, 由 Object.prototype.toString 确定。 @@ -619,7 +619,7 @@ test('assert.typeOf', () => { ## notTypeOf -- **类型:** `(value: T, name: string, message?: string) => void` +- **类型:** `(value: T, name: string, message?: string) => void` 断言 `value` 的类型不是 `name`,由 Object.prototype.toString 确定。 @@ -633,7 +633,7 @@ test('assert.notTypeOf', () => { ## instanceOf -- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is T` +- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is T` 断言 `value` 是 `constructor` 的实例。 @@ -660,7 +660,7 @@ test('assert.instanceOf', () => { ## notInstanceOf -- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is Exclude` +- **类型:** `(value: T, constructor: Function, message?: string) => asserts value is Exclude` 断言 `value` 不是 `constructor` 的实例。 @@ -686,7 +686,7 @@ test('assert.instanceOf', () => { ## include -- **类型:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: WeakSet, needle: T, message?: string) => void` @@ -710,7 +710,7 @@ test('assert.include', () => { ## notInclude -- **类型:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: WeakSet, needle: T, message?: string) => void` @@ -734,7 +734,7 @@ test('assert.notInclude', () => { ## deepInclude -- **类型:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` @@ -755,7 +755,7 @@ test('assert.deepInclude', () => { ## notDeepInclude -- **类型:** +- **类型:** - `(haystack: string, needle: string, message?: string) => void` - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` @@ -776,7 +776,7 @@ test('assert.notDeepInclude', () => { ## nestedInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`。 可以用来断言对象中是否包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 @@ -791,7 +791,7 @@ test('assert.nestedInclude', () => { ## notNestedInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 @@ -806,7 +806,7 @@ test('assert.nestedInclude', () => { ## deepNestedInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 @@ -824,7 +824,7 @@ test('assert.deepNestedInclude', () => { ## notDeepNestedInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 @@ -842,7 +842,7 @@ test('assert.notDeepNestedInclude', () => { ## ownInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性。 @@ -856,7 +856,7 @@ test('assert.ownInclude', () => { ## notOwnInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性 @@ -877,7 +877,7 @@ test('assert.notOwnInclude', () => { ## deepOwnInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性并检查深度相等性。 @@ -891,7 +891,7 @@ test('assert.deepOwnInclude', () => { ## notDeepOwnInclude -- **类型:** `(haystack: any, needle: any, message?: string) => void` +- **类型:** `(haystack: any, needle: any, message?: string) => void` 断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 @@ -905,7 +905,7 @@ test('assert.notDeepOwnInclude', () => { ## match -- **类型:** `(value: string, regexp: RegExp, message?: string) => void` +- **类型:** `(value: string, regexp: RegExp, message?: string) => void` 断言 `value` 匹配正则表达式 `regexp`。 @@ -919,7 +919,7 @@ test('assert.match', () => { ## notMatch -- **类型:** `(value: string, regexp: RegExp, message?: string) => void` +- **类型:** `(value: string, regexp: RegExp, message?: string) => void` 断言 `value` 不匹配正则表达式 `regexp`。 @@ -933,7 +933,7 @@ test('assert.notMatch', () => { ## property -- **类型:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` 断言 `object` 具有由 `property` 指定的直接或继承属性。 @@ -948,7 +948,7 @@ test('assert.property', () => { ## notProperty -- **类型:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` 断言 `object` 没有由 `property` 指定的直接或继承属性。 @@ -962,7 +962,7 @@ test('assert.notProperty', () => { ## propertyVal -- **类型:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` 断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 @@ -976,7 +976,7 @@ test('assert.notPropertyVal', () => { ## notPropertyVal -- **类型:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` 断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 @@ -991,7 +991,7 @@ test('assert.notPropertyVal', () => { ## deepPropertyVal -- **类型:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` 断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 @@ -1007,7 +1007,7 @@ test('assert.deepPropertyVal', () => { ## notDeepPropertyVal -- **类型:** `(object: T, property: string, value: V, message?: string) => void` +- **类型:** `(object: T, property: string, value: V, message?: string) => void` 断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 @@ -1029,7 +1029,7 @@ test('assert.deepPropertyVal', () => { ## nestedProperty -- **类型:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` 断言 `object` 具有由 `property` 指定的直接或继承属性,它可以是一个字符串,使用点和括号表示法来引用嵌套的引用。 @@ -1043,7 +1043,7 @@ test('assert.deepPropertyVal', () => { ## notNestedProperty -- **类型:** `(object: T, property: string, message?: string) => void` +- **类型:** `(object: T, property: string, message?: string) => void` 断言 `object` 没有由 `property` 指定的属性,它可以是一个字符串,使用点和括号表示法来引用嵌套的引用。该属性不能存在于对象上,也不能存在于其原型链中的任何地方。 @@ -1057,7 +1057,7 @@ test('assert.deepPropertyVal', () => { ## nestedPropertyVal -- **类型:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` 断言 `object` 具有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用严格相等检查 (===)。 @@ -1071,7 +1071,7 @@ test('assert.nestedPropertyVal', () => { ## notNestedPropertyVal -- **类型:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` 断言 `object` 没有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用严格相等检查 (===)。 @@ -1094,7 +1094,7 @@ test('assert.notNestedPropertyVal', () => { ## deepNestedPropertyVal -- **类型:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` 断言 `object` 具有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用深度相等检查。 @@ -1117,7 +1117,7 @@ test('assert.notNestedPropertyVal', () => { ## notDeepNestedPropertyVal -- **类型:** `(object: T, property: string, value: any, message?: string) => void` +- **类型:** `(object: T, property: string, value: any, message?: string) => void` 断言 `object` 没有由 `property` 指定的属性,其值为 `value` 给出。 `property` 可以使用点和方括号表示法进行嵌套引用。使用深度相等检查。 @@ -1145,7 +1145,7 @@ test('assert.notDeepNestedPropertyVal', () => { ## lengthOf -- **类型:** `(object: T, length: number, message?: string) => void` +- **类型:** `(object: T, length: number, message?: string) => void` 断言 `object` 具有预期的 `length` 或 `size` 值。 @@ -1170,7 +1170,7 @@ test('assert.lengthOf', () => { ## hasAnyKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 至少拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1199,7 +1199,7 @@ test('assert.hasAnyKeys', () => { ## hasAllKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 拥有且仅拥有所有提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1227,7 +1227,7 @@ test('assert.hasAllKeys', () => { ## containsAllKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 拥有所有提供的 `keys`,但可能还有更多未列出的键。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1267,7 +1267,7 @@ test('assert.containsAllKeys', () => { ## doesNotHaveAnyKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 不拥有任何提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1299,7 +1299,7 @@ test('assert.doesNotHaveAnyKeys', () => { ## doesNotHaveAllKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 至少不拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1332,7 +1332,7 @@ test('assert.hasAnyKeys', () => { ## hasAnyDeepKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 至少拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 @@ -1377,7 +1377,7 @@ test('assert.hasAnyDeepKeys', () => { ## hasAllDeepKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 拥有且仅拥有所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 @@ -1405,7 +1405,7 @@ test('assert.hasAnyDeepKeys', () => { ## containsAllDeepKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 包含所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1439,7 +1439,7 @@ test('assert.containsAllDeepKeys', () => { ## doesNotHaveAnyDeepKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 不拥有任何提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1473,7 +1473,7 @@ test('assert.doesNotHaveAnyDeepKeys', () => { ## doesNotHaveAllDeepKeys -- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` +- **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` 断言 `object` 至少不拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 @@ -1507,10 +1507,10 @@ test('assert.doesNotHaveAllDeepKeys', () => { ## throws -- **类型:** +- **类型:** - `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` - `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` -- **别名:** +- **别名:** - `throw` - `Throw` @@ -1549,8 +1549,8 @@ test('assert.throws', () => { ## doesNotThrow -- **类型:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` -- **类型:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` +- **类型:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` +- **类型:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` 如果 `errorLike` 是一个 Error 构造函数,则断言 `fn` 不会 抛出一个 errorLike 实例的错误。如果 `errorLike` 是一个 Error 实例,则断言抛出的错误不是 与 errorLike 是同一个实例。如果提供了 `errMsgMatcher`,它还断言抛出的错误不会 具有与 `errMsgMatcher` 相匹配的消息。 @@ -1571,7 +1571,7 @@ test('assert.doesNotThrow', () => { ## operator -- **类型:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` +- **类型:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` 使用 `operator` 比较 `val1` 和 `val2`。 @@ -1585,8 +1585,8 @@ test('assert.operator', () => { ## closeTo -- **类型:** `(actual: number, expected: number, delta: number, message?: string) => void` -- **别名:** `approximately` +- **类型:** `(actual: number, expected: number, delta: number, message?: string) => void` +- **别名:** `approximately` 断言 `actual` 导出 `expected`,误差范围控制在 +/- `delta` 内。 @@ -1600,7 +1600,7 @@ test('assert.closeTo', () => { ## sameMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 具有相同的成员,但顺序可以不同。使用严格相等检查 (===)。 @@ -1614,7 +1614,7 @@ test('assert.sameMembers', () => { ## notSameMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 不具有相同的成员,但顺序可以不同。使用严格相等检查 (===)。 @@ -1628,7 +1628,7 @@ test('assert.sameMembers', () => { ## sameDeepMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 具有相同的成员,但顺序可以不同。使用深度相等检查。 @@ -1646,7 +1646,7 @@ test('assert.sameDeepMembers', () => { ## notSameDeepMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 不具有相同的成员,但顺序可以不同。使用深度相等检查。 @@ -1664,7 +1664,7 @@ test('assert.sameDeepMembers', () => { ## sameOrderedMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 具有相同的成员,并且顺序也相同。使用严格相等检查 (===)。 @@ -1678,7 +1678,7 @@ test('assert.sameOrderedMembers', () => { ## notSameOrderedMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 的成员不相同或顺序不同。使用严格相等比较 (===)。 @@ -1696,7 +1696,7 @@ test('assert.notSameOrderedMembers', () => { ## sameDeepOrderedMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 的成员相同且顺序相同。使用深度相等比较。 @@ -1714,7 +1714,7 @@ test('assert.sameDeepOrderedMembers', () => { ## notSameDeepOrderedMembers -- **类型:** `(set1: T[], set2: T[], message?: string) => void` +- **类型:** `(set1: T[], set2: T[], message?: string) => void` 断言 `set1` 和 `set2` 的成员不相同或顺序不同。使用深度相等比较。 @@ -1737,7 +1737,7 @@ test('assert.notSameDeepOrderedMembers', () => { ## includeMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 被包含在 `superset` 中,顺序可以不同。使用严格相等比较 (===)。忽略重复项。 @@ -1751,7 +1751,7 @@ test('assert.includeMembers', () => { ## notIncludeMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 未被包含在 `superset` 中,顺序可以不同。使用严格相等比较 (===)。忽略重复项。 @@ -1765,7 +1765,7 @@ test('assert.notIncludeMembers', () => { ## includeDeepMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 被包含在 `superset` 中,顺序可以不同。使用深度相等比较。忽略重复项。 @@ -1783,7 +1783,7 @@ test('assert.includeDeepMembers', () => { ## notIncludeDeepMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 未被包含在 `superset` 中,顺序可以不同。使用深度相等比较。忽略重复项。 @@ -1801,7 +1801,7 @@ test('assert.notIncludeDeepMembers', () => { ## includeOrderedMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用严格相等比较 (===)。 @@ -1815,7 +1815,7 @@ test('assert.includeOrderedMembers', () => { ## notIncludeOrderedMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 未被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用严格相等比较 (===)。 @@ -1838,7 +1838,7 @@ test('assert.notIncludeOrderedMembers', () => { ## includeDeepOrderedMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用深度相等比较。 @@ -1856,7 +1856,7 @@ test('assert.includeDeepOrderedMembers', () => { ## notIncludeDeepOrderedMembers -- **类型:** `(superset: T[], subset: T[], message?: string) => void` +- **类型:** `(superset: T[], subset: T[], message?: string) => void` 断言 `subset` 未被包含在 `superset` 中,顺序相同,从 `superset` 中的第一个元素开始。使用深度相等比较。 @@ -1884,7 +1884,7 @@ test('assert.includeDeepOrderedMembers', () => { ## oneOf -- **类型:** `(inList: T, list: T[], message?: string) => void` +- **类型:** `(inList: T, list: T[], message?: string) => void` 断言非对象、非数组值 `inList` 出现在扁平数组 list 中。 @@ -1898,7 +1898,7 @@ test('assert.oneOf', () => { ## changes -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 用于修改 `property` 所属 `object`。 @@ -1916,7 +1916,7 @@ test('assert.changes', () => { ## changesBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 通过 `change` 修改 `property` 所属的 `object`。 @@ -1934,7 +1934,7 @@ test('assert.changesBy', () => { ## doesNotChange -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的 `object`。 @@ -1952,7 +1952,7 @@ test('assert.doesNotChange', () => { ## changesButNotBy -- **类型:** `(modifier: Function, object: T, property: string, change:number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change:number, message?: string) => void` 断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的所属对象。 @@ -1970,7 +1970,7 @@ test('assert.changesButNotBy', () => { ## increases -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 会增加数值类型对象属性。 @@ -1988,7 +1988,7 @@ test('assert.increases', () => { ## increasesBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 @@ -2004,7 +2004,7 @@ test('assert.increasesBy', () => { ## doesNotIncrease -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 不会增加数值类型对象属性。 @@ -2022,7 +2022,7 @@ test('assert.doesNotIncrease', () => { ## increasesButNotBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 不会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 @@ -2040,7 +2040,7 @@ test('assert.increasesButNotBy', () => { ## decreases -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 不会通过 `change` 增加数值类型对象属性或 `函数` 返回值的数值。 @@ -2058,7 +2058,7 @@ test('assert.decreases', () => { ## decreasesBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 会通过 `change` 减少数值类型对象属性或 `函数` 返回值的数值。 @@ -2076,7 +2076,7 @@ test('assert.decreasesBy', () => { ## doesNotDecrease -- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` 断言 `函数` 不会减少数值类型对象属性。 @@ -2094,7 +2094,7 @@ test('assert.doesNotDecrease', () => { ## doesNotDecreaseBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 不会通过 `change` 减少数值类型对象属性或 `函数`返回值的数值。 @@ -2112,7 +2112,7 @@ test('assert.doesNotDecreaseBy', () => { ## decreasesButNotBy -- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` +- **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` 断言 `函数` 不会通过 change 减少数值类型对象属性或 `函数` 返回值的数值。 @@ -2130,7 +2130,7 @@ test('assert.decreasesButNotBy', () => { ## ifError -- **类型:** `(object: T, message?: string) => void` +- **类型:** `(object: T, message?: string) => void` 断言 `object` 是否为假值,如果它是真值则抛出错误。这是为了允许 chai 作为 Node 的 assert 类的一个直接替代品。 @@ -2145,8 +2145,8 @@ test('assert.ifError', () => { ## isExtensible -- **类型:** `(object: T, message?: string) => void` -- **别名:** `extensible` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `extensible` 断言 `object` 是可扩展的(可以向其添加新的属性)。 @@ -2160,8 +2160,8 @@ test('assert.isExtensible', () => { ## isNotExtensible -- **类型:** `(object: T, message?: string) => void` -- **别名:** `notExtensible` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `notExtensible` 断言 `object` 是不可扩展的 (不能添加新属性)。 @@ -2181,8 +2181,8 @@ test('assert.isNotExtensible', () => { ## isSealed -- **类型:** `(object: T, message?: string) => void` -- **别名:** `sealed` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `sealed` 断言 `object` 是密封的(不能向其添加新的属性,也不能删除其现有属性)。 @@ -2200,8 +2200,8 @@ test('assert.isSealed', () => { ## isNotSealed -- **类型:** `(object: T, message?: string) => void` -- **别名:** `notSealed` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `notSealed` 断言 `object` 未被密封(可以添加新属性,并且可以删除其现有属性)。 @@ -2215,8 +2215,8 @@ test('assert.isNotSealed', () => { ## isFrozen -- **类型:** `(object: T, message?: string) => void` -- **别名:** `frozen` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `frozen` 断言 `object` 是冻结的(不能向其添加新的属性,也不能修改其现有属性)。 @@ -2231,8 +2231,8 @@ test('assert.isFrozen', () => { ## isNotFrozen -- **类型:** `(object: T, message?: string) => void` -- **别名:** `notFrozen` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `notFrozen` 断言 `object` 未被冻结(可以向其添加新属性,并且可以修改其现有属性)。 @@ -2246,8 +2246,8 @@ test('assert.isNotFrozen', () => { ## isEmpty -- **类型:** `(target: T, message?: string) => void` -- **别名:** `empty` +- **类型:** `(target: T, message?: string) => void` +- **别名:** `empty` 断言 `target` 不包含任何值。对于数组和字符串,它检查 length 属性。对于 Map 和 Set 实例,它检查 size 属性。对于非函数对象,它获取自身可枚举字符串键的数量。 @@ -2264,8 +2264,8 @@ test('assert.isEmpty', () => { ## isNotEmpty -- **类型:** `(object: T, message?: string) => void` -- **别名:** `notEmpty` +- **类型:** `(object: T, message?: string) => void` +- **别名:** `notEmpty` 断言 `target` 包含值。对于数组和字符串,它检查 length 属性。对于 Map 和 Set 实例,它检查 size 属性。对于非函数对象,它获取自身可枚举字符串键的数量。 diff --git a/api/expect.md b/api/expect.md index f57ff851..322862de 100644 --- a/api/expect.md +++ b/api/expect.md @@ -41,7 +41,7 @@ expect(input).toBe(2) // jest API ## assert -- **类型:** `Chai.AssertStatic` +- **类型:** `Chai.AssertStatic` Vitest reexports chai's [`assert` API](https://www.chaijs.com/api/assert/) as `expect.assert` for convenience. You can see the supported methods on the [Assert API page](/api/assert). @@ -332,7 +332,7 @@ test('we don\'t have apples', () => { ## toBeNullable -- **类型:** `() => Awaitable` +- **类型:** `() => Awaitable` `toBeNullable` simply asserts if something is nullable (`null` or `undefined`). From 7615c11b943bb7b61198f4db7db039367ecf1103 Mon Sep 17 00:00:00 2001 From: noise Date: Tue, 11 Nov 2025 23:15:57 +0800 Subject: [PATCH 4/8] typo: update /guide/assert --- api/assert.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/assert.md b/api/assert.md index eb755b56..566c1444 100644 --- a/api/assert.md +++ b/api/assert.md @@ -426,7 +426,7 @@ test('assert.isNotFunction', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 是一个类型为 'Object' 的对象 (由 Object.prototype.toString 确定)。 此断言不匹配子类对象。 +断言 `value` 是一个类型为 Object 的对象 (由 Object.prototype.toString 确定)。 此断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' @@ -442,7 +442,7 @@ test('assert.isObject', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 不是一个类型为 'Object' 的对象 (如 Object.prototype.toString 确定)。 该断言不匹配子类对象。 +断言 `value` 不是一个类型为 Object 的对象 (如 Object.prototype.toString 确定)。 该断言不匹配子类对象。 ```ts import { assert, test } from 'vitest' From 2f76993878bdcac371fbb60df8d5a0fd026ccbe2 Mon Sep 17 00:00:00 2001 From: noise Date: Wed, 12 Nov 2025 00:11:52 +0800 Subject: [PATCH 5/8] typo: update /guide/assert --- api/assert.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/assert.md b/api/assert.md index 566c1444..cbb016ff 100644 --- a/api/assert.md +++ b/api/assert.md @@ -83,7 +83,7 @@ test('assert.equal', () => { - **类型:** `(actual: T, expected: T, message?: string) => void` -断言 `actual` 和 `expected` 非严格不等(!=). +断言 `actual` 和 `expected` 非严格不等(!=)。 ```ts import { assert, test } from 'vitest' @@ -153,7 +153,7 @@ test('assert.isAbove', () => { - **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` -断言 `valueToCheck` 大于或等于 (>=) `valueToBeAtLeast`。 +断言 `valueToCheck` 大于等于 (>=) `valueToBeAtLeast`。 ```ts import { assert, test } from 'vitest' @@ -182,7 +182,7 @@ test('assert.isBelow', () => { - **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` -断言 `valueToCheck` 小于或等于 (<=) `valueToBeAtMost`。 +断言 `valueToCheck` 小于等于 (<=) `valueToBeAtMost`。 ```ts import { assert, test } from 'vitest' @@ -808,7 +808,7 @@ test('assert.nestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 +断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -893,7 +893,7 @@ test('assert.deepOwnInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 +断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 ```ts import { assert, test } from 'vitest' @@ -1552,7 +1552,7 @@ test('assert.throws', () => { - **类型:** `(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string) => void` - **类型:** `(fn: () => void, errorLike?: ErrorConstructor | Error | null, errMsgMatcher?: RegExp | string | null, message?: string) => void` -如果 `errorLike` 是一个 Error 构造函数,则断言 `fn` 不会 抛出一个 errorLike 实例的错误。如果 `errorLike` 是一个 Error 实例,则断言抛出的错误不是 与 errorLike 是同一个实例。如果提供了 `errMsgMatcher`,它还断言抛出的错误不会 具有与 `errMsgMatcher` 相匹配的消息。 +如果 `errorLike` 是一个 Error 构造函数,则断言 `fn` 不会 抛出一个 errorLike 实例的错误。如果 `errorLike` 是一个 Error 实例,则断言抛出的错误不是与 errorLike 是同一个实例。如果提供了 `errMsgMatcher`,它还断言抛出的错误不会 具有与 `errMsgMatcher` 相匹配的消息。 ```ts import { assert, test } from 'vitest' @@ -1588,7 +1588,7 @@ test('assert.operator', () => { - **类型:** `(actual: number, expected: number, delta: number, message?: string) => void` - **别名:** `approximately` -断言 `actual` 导出 `expected`,误差范围控制在 +/- `delta` 内。 +断言 `actual` 等于 `expected`,误差范围控制在 +/- `delta` 内。 ```ts import { assert, test } from 'vitest' @@ -2096,7 +2096,7 @@ test('assert.doesNotDecrease', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 `函数` 不会通过 `change` 减少数值类型对象属性或 `函数`返回值的数值。 +断言 `函数` 不会通过 `change` 减少数值类型对象属性或 `函数` 返回值的数值。 ```ts import { assert, test } from 'vitest' From 9b80d712ec4ca22268d3445d2410006e8ef19e31 Mon Sep 17 00:00:00 2001 From: noise Date: Wed, 12 Nov 2025 00:15:03 +0800 Subject: [PATCH 6/8] typo: update /guide/assert --- api/assert.md | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/api/assert.md b/api/assert.md index cbb016ff..51f494fe 100644 --- a/api/assert.md +++ b/api/assert.md @@ -139,7 +139,7 @@ test('assert.notDeepEqual', () => { - **类型:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` -断言 `valueToCheck` 严格大于 (>) `valueToBeAbove`。 +断言 `valueToCheck` 严格大于 (>) `valueToBeAbove` 。 ```ts import { assert, test } from 'vitest' @@ -153,7 +153,7 @@ test('assert.isAbove', () => { - **类型:** `(valueToCheck: number, valueToBeAtLeast: number, message?: string) => void` -断言 `valueToCheck` 大于等于 (>=) `valueToBeAtLeast`。 +断言 `valueToCheck` 大于等于 (>=) `valueToBeAtLeast` 。 ```ts import { assert, test } from 'vitest' @@ -168,7 +168,7 @@ test('assert.isAtLeast', () => { - **类型:** `(valueToCheck: number, valueToBeBelow: number, message?: string) => void` -断言 `valueToCheck` 严格小于 (<) `valueToBeBelow`。 +断言 `valueToCheck` 严格小于 (<) `valueToBeBelow` 。 ```ts import { assert, test } from 'vitest' @@ -182,7 +182,7 @@ test('assert.isBelow', () => { - **类型:** `(valueToCheck: number, valueToBeAtMost: number, message?: string) => void` -断言 `valueToCheck` 小于等于 (<=) `valueToBeAtMost`。 +断言 `valueToCheck` 小于等于 (<=) `valueToBeAtMost` 。 ```ts import { assert, test } from 'vitest' @@ -692,7 +692,7 @@ test('assert.instanceOf', () => { - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言数组中是否包含一个值、字符串中是否包含一个子字符串、或者对象中是否包含一组属性。 +断言 `haystack` 包含 `needle` 。可以用来断言数组中是否包含一个值、字符串中是否包含一个子字符串、或者对象中是否包含一组属性。 ```ts import { assert, test } from 'vitest' @@ -716,7 +716,7 @@ test('assert.include', () => { - `(haystack: WeakSet, needle: T, message?: string) => void` - `(haystack: T, needle: Partial, message?: string) => void` -断言 `haystack` 不包含 `needle`。可以用来断言数组中是否不包含一个值、字符串中是否不包含一个子字符串、或者对象中是否不包含一组属性。 +断言 `haystack` 不包含 `needle` 。可以用来断言数组中是否不包含一个值、字符串中是否不包含一个子字符串、或者对象中是否不包含一组属性。 ```ts import { assert, test } from 'vitest' @@ -739,7 +739,7 @@ test('assert.notInclude', () => { - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言数组中是否包含一个值或对象中是否包含一组属性。使用深度相等。 +断言 `haystack` 包含 `needle` 。可以用来断言数组中是否包含一个值或对象中是否包含一组属性。使用深度相等。 ```ts import { assert, test } from 'vitest' @@ -760,7 +760,7 @@ test('assert.deepInclude', () => { - `(haystack: readonly T[] | ReadonlySet | ReadonlyMap, needle: T, message?: string) => void` - `(haystack: T, needle: T extends WeakSet ? never : Partial, message?: string) => void` -断言 `haystack` 不包含 `needle`。可以用来断言数组中是否不包含一个值或对象中是否不包含一组属性。使用深度相等。 +断言 `haystack` 不包含 `needle` 。可以用来断言数组中是否不包含一个值或对象中是否不包含一组属性。使用深度相等。 ```ts import { assert, test } from 'vitest' @@ -778,7 +778,7 @@ test('assert.notDeepInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。 可以用来断言对象中是否包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 +断言 `haystack` 包含 `needle` 。 可以用来断言对象中是否包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -793,7 +793,7 @@ test('assert.nestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 +断言 `haystack` 不包含 `needle` 。可以用来断言对象中是否不包含一组属性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -808,7 +808,7 @@ test('assert.nestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 +断言 `haystack` 包含 `needle` 。可以用来断言对象中是否包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -826,7 +826,7 @@ test('assert.deepNestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 +断言 `haystack` 不包含 `needle` 。可以用来断言对象中是否不包含一组属性,同时检查深度相等性。允许使用点和括号表示法来引用嵌套属性。属性名中的 ‘[]’ 和 ‘.’ 可以使用双反斜杠转义。 ```ts import { assert, test } from 'vitest' @@ -844,7 +844,7 @@ test('assert.notDeepNestedInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性。 +断言 `haystack` 包含 `needle` 。可以用来断言对象中是否包含一组属性,同时忽略继承的属性。 ```ts import { assert, test } from 'vitest' @@ -858,7 +858,7 @@ test('assert.ownInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性 +断言 `haystack` 包含 `needle` 。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性 ```ts import { assert, test } from 'vitest' @@ -879,7 +879,7 @@ test('assert.notOwnInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 包含 `needle`。可以用来断言对象中是否包含一组属性,同时忽略继承的属性并检查深度相等性。 +断言 `haystack` 包含 `needle` 。可以用来断言对象中是否包含一组属性,同时忽略继承的属性并检查深度相等性。 ```ts import { assert, test } from 'vitest' @@ -893,7 +893,7 @@ test('assert.deepOwnInclude', () => { - **类型:** `(haystack: any, needle: any, message?: string) => void` -断言 `haystack` 不包含 `needle`。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 +断言 `haystack` 不包含 `needle` 。可以用来断言对象中是否不包含一组属性,同时忽略继承的属性并检查深度相等性。 ```ts import { assert, test } from 'vitest' @@ -907,7 +907,7 @@ test('assert.notDeepOwnInclude', () => { - **类型:** `(value: string, regexp: RegExp, message?: string) => void` -断言 `value` 匹配正则表达式 `regexp`。 +断言 `value` 匹配正则表达式 `regexp` 。 ```ts import { assert, test } from 'vitest' @@ -921,7 +921,7 @@ test('assert.match', () => { - **类型:** `(value: string, regexp: RegExp, message?: string) => void` -断言 `value` 不匹配正则表达式 `regexp`。 +断言 `value` 不匹配正则表达式 `regexp` 。 ```ts import { assert, test } from 'vitest' @@ -964,7 +964,7 @@ test('assert.notProperty', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 +断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value` 。使用严格相等检查(===)。 ```ts import { assert, test } from 'vitest' @@ -978,7 +978,7 @@ test('assert.notPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用严格相等检查(===)。 +断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value` 。使用严格相等检查(===)。 ```ts import { assert, test } from 'vitest' @@ -993,7 +993,7 @@ test('assert.notPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 +断言 `object` 具有由 `property` 指定的直接或继承属性,其值为 `value` 。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1009,7 +1009,7 @@ test('assert.deepPropertyVal', () => { - **类型:** `(object: T, property: string, value: V, message?: string) => void` -断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value`。使用深度相等检查。 +断言 `object` 没有由 `property` 指定的直接或继承属性,其值为 `value` 。使用深度相等检查。 ```ts import { assert, test } from 'vitest' @@ -1172,7 +1172,7 @@ test('assert.lengthOf', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 至少拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 至少拥有一个提供的 `keys` 。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1201,7 +1201,7 @@ test('assert.hasAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 拥有且仅拥有所有提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 拥有且仅拥有所有提供的 `keys` 。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1269,7 +1269,7 @@ test('assert.containsAllKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 不拥有任何提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 不拥有任何提供的 `keys` 。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1301,7 +1301,7 @@ test('assert.doesNotHaveAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 至少不拥有一个提供的 `keys`。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 至少不拥有一个提供的 `keys` 。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1334,7 +1334,7 @@ test('assert.hasAnyKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 至少拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 +断言 `object` 至少拥有一个提供的 `keys` 。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1379,7 +1379,7 @@ test('assert.hasAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 拥有且仅拥有所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 +断言 `object` 拥有且仅拥有所有提供的 `keys` 。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 keys 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1407,7 +1407,7 @@ test('assert.hasAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 包含所有提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 包含所有提供的 `keys` 。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1441,7 +1441,7 @@ test('assert.containsAllDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 不拥有任何提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 不拥有任何提供的 `keys` 。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1475,7 +1475,7 @@ test('assert.doesNotHaveAnyDeepKeys', () => { - **类型:** `(object: T, keys: Array | { [key: string]: any }, message?: string) => void` -断言 `object` 至少不拥有一个提供的 `keys`。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 +断言 `object` 至少不拥有一个提供的 `keys` 。由于 Set 和 Map 可以拥有对象作为键,你可以使用这个断言来进行深度比较。你也可以提供一个单独的对象而不是一个 `keys` 数组,它的键将被用作预期的键集。 ```ts import { assert, test } from 'vitest' @@ -1573,7 +1573,7 @@ test('assert.doesNotThrow', () => { - **类型:** `(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string) => void` -使用 `operator` 比较 `val1` 和 `val2`。 +使用 `operator` 比较 `val1` 和 `val2` 。 ```ts import { assert, test } from 'vitest' @@ -1900,7 +1900,7 @@ test('assert.oneOf', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 `函数` 用于修改 `property` 所属 `object`。 +断言 `函数` 用于修改 `property` 所属 `object` 。 ```ts import { assert, test } from 'vitest' @@ -1918,7 +1918,7 @@ test('assert.changes', () => { - **类型:** `(modifier: Function, object: T, property: string, change: number, message?: string) => void` -断言 `函数` 通过 `change` 修改 `property` 所属的 `object`。 +断言 `函数` 通过 `change` 修改 `property` 所属的 `object` 。 ```ts import { assert, test } from 'vitest' @@ -1936,7 +1936,7 @@ test('assert.changesBy', () => { - **类型:** `(modifier: Function, object: T, property: string, message?: string) => void` -断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的 `object`。 +断言 `函数` 不会通过 `change` 修改 `property` 或 `函数` 返回值的 `object` 。 ```ts import { assert, test } from 'vitest' From f4db85f7ea2ee50a80ccc24446e37a0e07749930 Mon Sep 17 00:00:00 2001 From: noise Date: Wed, 12 Nov 2025 00:18:33 +0800 Subject: [PATCH 7/8] typo: update /guide/assert --- api/assert.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/api/assert.md b/api/assert.md index 51f494fe..343c5262 100644 --- a/api/assert.md +++ b/api/assert.md @@ -38,7 +38,7 @@ test('assert.fail', () => { - **类型:** `(value: T, message?: string) => asserts value` - **Alias** `ok` -断言给定的 `value` 是 true。 +断言给定的 `value` 是 true 。 ```ts import { assert, test } from 'vitest' @@ -54,7 +54,7 @@ test('assert.isOk', () => { - **类型:** `(value: T, message?: string) => void` - **Alias** `notOk` -断言给定的 `value` 是 false。 +断言给定的 `value` 是 false 。 ```ts import { assert, test } from 'vitest' @@ -197,7 +197,7 @@ test('assert.isAtMost', () => { - **类型:** `(value: T, message?: string) => asserts value is true` -断言 `value` 是 true。 +断言 `value` 是 true 。 ```ts import { assert, test } from 'vitest' @@ -213,7 +213,7 @@ test('assert.isTrue', () => { - **类型:** `(value: T, message?: string) => asserts value is Exclude` -断言 `value` 不是 true。 +断言 `value` 不是 true 。 ```ts import { assert, test } from 'vitest' @@ -229,7 +229,7 @@ test('assert.isNotTrue', () => { - **类型:** `(value: T, message?: string) => asserts value is false` -断言 `value` 是 false。 +断言 `value` 是 false 。 ```ts import { assert, test } from 'vitest' @@ -245,7 +245,7 @@ test('assert.isFalse', () => { - **类型:** `(value: T, message?: string) => asserts value is Exclude` -断言 `value` 不是 false。 +断言 `value` 不是 false 。 ```ts import { assert, test } from 'vitest' @@ -261,7 +261,7 @@ test('assert.isNotFalse', () => { - **类型:** `(value: T, message?: string) => asserts value is null` -断言 `value` 是 null。 +断言 `value` 是 null 。 ```ts import { assert, test } from 'vitest' @@ -277,7 +277,7 @@ test('assert.isNull', () => { - **类型:** `(value: T, message?: string) => asserts value is Exclude` -断言 `value` 不是 null。 +断言 `value` 不是 null 。 ```ts import { assert, test } from 'vitest' @@ -293,7 +293,7 @@ test('assert.isNotNull', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 是 NaN。 +断言 `value` 是 NaN 。 ```ts import { assert, test } from 'vitest' @@ -309,7 +309,7 @@ test('assert.isNaN', () => { - **类型:** `(value: T, message?: string) => void` -断言 `value` 不是 NaN。 +断言 `value` 不是 NaN 。 ```ts import { assert, test } from 'vitest' @@ -325,7 +325,7 @@ test('assert.isNotNaN', () => { - **类型:** `(value: T, message?: string) => asserts value is NonNullable` -断言 `value` 既不是 null 也不是 undefined。 +断言 `value` 既不是 null 也不是 undefined 。 ```ts import { assert, test } from 'vitest' @@ -341,7 +341,7 @@ test('assert.exists', () => { - **类型:** `(value: T, message?: string) => asserts value is null | undefined` -断言 `value` 是 null 或 undefined。 +断言 `value` 是 null 或 undefined 。 ```ts import { assert, test } from 'vitest' @@ -359,7 +359,7 @@ test('assert.notExists', () => { - **类型:** `(value: T, message?: string) => asserts value is undefined` -断言 `value` 是 undefined。 +断言 `value` 是 undefined 。 ```ts import { assert, test } from 'vitest' @@ -375,7 +375,7 @@ test('assert.isUndefined', () => { - **类型:** `(value: T, message?: string) => asserts value is Exclude` -断言 `value` 不是 undefined。 +断言 `value` 不是 undefined 。 ```ts import { assert, test } from 'vitest' From e003d8a4b4454f40cb9ad19fee9ff158912af630 Mon Sep 17 00:00:00 2001 From: noise Date: Wed, 12 Nov 2025 00:28:34 +0800 Subject: [PATCH 8/8] typo: update /guide/assert --- api/assert.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/assert.md b/api/assert.md index 343c5262..78fcd770 100644 --- a/api/assert.md +++ b/api/assert.md @@ -83,7 +83,7 @@ test('assert.equal', () => { - **类型:** `(actual: T, expected: T, message?: string) => void` -断言 `actual` 和 `expected` 非严格不等(!=)。 +断言 `actual` 和 `expected` 非严格不等 (!=)。 ```ts import { assert, test } from 'vitest' @@ -139,7 +139,7 @@ test('assert.notDeepEqual', () => { - **类型:** `(valueToCheck: number, valueToBeAbove: number, message?: string) => void` -断言 `valueToCheck` 严格大于 (>) `valueToBeAbove` 。 +断言 `valueToCheck` 严格大于 (>) `valueToBeAbove` 。 ```ts import { assert, test } from 'vitest'