// Derived from Node.js v24.16.0 (MIT; Copyright Node.js contributors, and Joyent, Inc. and // other Node contributors). See LICENSE-node. // node:internal/test_runner/assert.js: the map of names TestContext#assert copies onto // each test's `t.assert`, seeded from node:assert and extendable through // `test.assert.register(name, fn)`. import { assert } from "../assert"; import { invalidArgType } from "../errors"; const METHODS_TO_COPY = [ "deepEqual", "deepStrictEqual", "doesNotMatch", "doesNotReject", "doesNotThrow", "equal", "fail", "ifError", "match", "notDeepEqual", "notDeepStrictEqual", "notEqual", "partialDeepStrictEqual", "rejects", "strictEqual", "throws", ] as const; type AssertMap = Map unknown>; let assertMap: AssertMap | undefined; export function getAssertionMap(): AssertMap { if (assertMap === undefined) { assertMap = new Map(); const methods = assert as unknown as Record unknown>; for (const name of METHODS_TO_COPY) { const method = methods[name]; if (method) assertMap.set(name, method); } } return assertMap; } export function register(name: unknown, fn: unknown): void { if (typeof name !== "string") throw invalidArgType("name", "of type string", name); if (typeof fn !== "function") throw invalidArgType("fn", "of type function", fn); getAssertionMap().set(name, fn as (...args: unknown[]) => unknown); }