@@ -564,6 +564,23 @@ declare module "node:test" {
564564 /**
565565 * An object containing assertion methods bound to the test context.
566566 * The top-level functions from the `node:assert` module are exposed here for the purpose of creating test plans.
567+ *
568+ * **Note:** Some of the functions from `node:assert` contain type assertions. If these are called via the
569+ * TestContext `assert` object, then the context parameter in the test's function signature **must be explicitly typed**
570+ * (ie. the parameter must have a type annotation), otherwise an error will be raised by the TypeScript compiler:
571+ * ```ts
572+ * import { test, type TestContext } from 'node:test';
573+ *
574+ * // The test function's context parameter must have a type annotation.
575+ * test('example', (t: TestContext) => {
576+ * t.assert.deepStrictEqual(actual, expected);
577+ * });
578+ *
579+ * // Omitting the type annotation will result in a compilation error.
580+ * test('example', t => {
581+ * t.assert.deepStrictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
582+ * });
583+ * ```
567584 * @since v22.2.0, v20.15.0
568585 */
569586 readonly assert : TestContextAssert ;
@@ -741,139 +758,29 @@ declare module "node:test" {
741758 */
742759 readonly mock : MockTracker ;
743760 }
744- interface TestContextAssert {
745- /**
746- * Identical to the `deepEqual` function from the `node:assert` module, but bound to the test context.
747- */
748- deepEqual : typeof import ( "node:assert" ) . deepEqual ;
749- /**
750- * Identical to the `deepStrictEqual` function from the `node:assert` module, but bound to the test context.
751- *
752- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
753- * type annotation, otherwise an error will be raised by the TypeScript compiler:
754- * ```ts
755- * import { test, type TestContext } from 'node:test';
756- *
757- * // The test function's context parameter must have a type annotation.
758- * test('example', (t: TestContext) => {
759- * t.assert.deepStrictEqual(actual, expected);
760- * });
761- *
762- * // Omitting the type annotation will result in a compilation error.
763- * test('example', t => {
764- * t.assert.deepStrictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
765- * });
766- * ```
767- */
768- deepStrictEqual : typeof import ( "node:assert" ) . deepStrictEqual ;
769- /**
770- * Identical to the `doesNotMatch` function from the `node:assert` module, but bound to the test context.
771- */
772- doesNotMatch : typeof import ( "node:assert" ) . doesNotMatch ;
773- /**
774- * Identical to the `doesNotReject` function from the `node:assert` module, but bound to the test context.
775- */
776- doesNotReject : typeof import ( "node:assert" ) . doesNotReject ;
777- /**
778- * Identical to the `doesNotThrow` function from the `node:assert` module, but bound to the test context.
779- */
780- doesNotThrow : typeof import ( "node:assert" ) . doesNotThrow ;
781- /**
782- * Identical to the `equal` function from the `node:assert` module, but bound to the test context.
783- */
784- equal : typeof import ( "node:assert" ) . equal ;
785- /**
786- * Identical to the `fail` function from the `node:assert` module, but bound to the test context.
787- */
788- fail : typeof import ( "node:assert" ) . fail ;
789- /**
790- * Identical to the `ifError` function from the `node:assert` module, but bound to the test context.
791- *
792- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
793- * type annotation, otherwise an error will be raised by the TypeScript compiler:
794- * ```ts
795- * import { test, type TestContext } from 'node:test';
796- *
797- * // The test function's context parameter must have a type annotation.
798- * test('example', (t: TestContext) => {
799- * t.assert.ifError(err);
800- * });
801- *
802- * // Omitting the type annotation will result in a compilation error.
803- * test('example', t => {
804- * t.assert.ifError(err); // Error: 't' needs an explicit type annotation.
805- * });
806- * ```
807- */
808- ifError : typeof import ( "node:assert" ) . ifError ;
809- /**
810- * Identical to the `match` function from the `node:assert` module, but bound to the test context.
811- */
812- match : typeof import ( "node:assert" ) . match ;
813- /**
814- * Identical to the `notDeepEqual` function from the `node:assert` module, but bound to the test context.
815- */
816- notDeepEqual : typeof import ( "node:assert" ) . notDeepEqual ;
817- /**
818- * Identical to the `notDeepStrictEqual` function from the `node:assert` module, but bound to the test context.
819- */
820- notDeepStrictEqual : typeof import ( "node:assert" ) . notDeepStrictEqual ;
821- /**
822- * Identical to the `notEqual` function from the `node:assert` module, but bound to the test context.
823- */
824- notEqual : typeof import ( "node:assert" ) . notEqual ;
825- /**
826- * Identical to the `notStrictEqual` function from the `node:assert` module, but bound to the test context.
827- */
828- notStrictEqual : typeof import ( "node:assert" ) . notStrictEqual ;
829- /**
830- * Identical to the `ok` function from the `node:assert` module, but bound to the test context.
831- *
832- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
833- * type annotation, otherwise an error will be raised by the TypeScript compiler:
834- * ```ts
835- * import { test, type TestContext } from 'node:test';
836- *
837- * // The test function's context parameter must have a type annotation.
838- * test('example', (t: TestContext) => {
839- * t.assert.ok(condition);
840- * });
841- *
842- * // Omitting the type annotation will result in a compilation error.
843- * test('example', t => {
844- * t.assert.ok(condition)); // Error: 't' needs an explicit type annotation.
845- * });
846- * ```
847- */
848- ok : typeof import ( "node:assert" ) . ok ;
849- /**
850- * Identical to the `rejects` function from the `node:assert` module, but bound to the test context.
851- */
852- rejects : typeof import ( "node:assert" ) . rejects ;
853- /**
854- * Identical to the `strictEqual` function from the `node:assert` module, but bound to the test context.
855- *
856- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
857- * type annotation, otherwise an error will be raised by the TypeScript compiler:
858- * ```ts
859- * import { test, type TestContext } from 'node:test';
860- *
861- * // The test function's context parameter must have a type annotation.
862- * test('example', (t: TestContext) => {
863- * t.assert.strictEqual(actual, expected);
864- * });
865- *
866- * // Omitting the type annotation will result in a compilation error.
867- * test('example', t => {
868- * t.assert.strictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
869- * });
870- * ```
871- */
872- strictEqual : typeof import ( "node:assert" ) . strictEqual ;
873- /**
874- * Identical to the `throws` function from the `node:assert` module, but bound to the test context.
875- */
876- throws : typeof import ( "node:assert" ) . throws ;
761+ interface TestContextAssert extends
762+ Pick <
763+ typeof import ( "assert" ) ,
764+ | "deepEqual"
765+ | "deepStrictEqual"
766+ | "doesNotMatch"
767+ | "doesNotReject"
768+ | "doesNotThrow"
769+ | "equal"
770+ | "fail"
771+ | "ifError"
772+ | "match"
773+ | "notDeepEqual"
774+ | "notDeepStrictEqual"
775+ | "notEqual"
776+ | "notStrictEqual"
777+ | "ok"
778+ | "partialDeepStrictEqual"
779+ | "rejects"
780+ | "strictEqual"
781+ | "throws"
782+ >
783+ {
877784 /**
878785 * This function implements assertions for snapshot testing.
879786 * ```js
0 commit comments