mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/node): add assert
property to test context object (#28904)
This commit is contained in:
parent
e12d9b4946
commit
016b02d374
3 changed files with 64 additions and 2 deletions
|
@ -4,10 +4,44 @@ import { primordials } from "ext:core/mod.js";
|
|||
const {
|
||||
PromisePrototypeThen,
|
||||
ArrayPrototypePush,
|
||||
ArrayPrototypeForEach,
|
||||
SafePromiseAll,
|
||||
SafePromisePrototypeFinally,
|
||||
} = primordials;
|
||||
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
||||
import assert from "node:assert";
|
||||
|
||||
const methodsToCopy = [
|
||||
"deepEqual",
|
||||
"deepStrictEqual",
|
||||
"doesNotMatch",
|
||||
"doesNotReject",
|
||||
"doesNotThrow",
|
||||
"equal",
|
||||
"fail",
|
||||
"ifError",
|
||||
"match",
|
||||
"notDeepEqual",
|
||||
"notDeepStrictEqual",
|
||||
"notEqual",
|
||||
"notStrictEqual",
|
||||
"partialDeepStrictEqual",
|
||||
"rejects",
|
||||
"strictEqual",
|
||||
"throws",
|
||||
];
|
||||
|
||||
/** `assert` object available via t.assert */
|
||||
let assertObject = undefined;
|
||||
function getAssertObject() {
|
||||
if (assertObject === undefined) {
|
||||
assertObject = { __proto__: null };
|
||||
ArrayPrototypeForEach(methodsToCopy, (method) => {
|
||||
assertObject[method] = assert[method];
|
||||
});
|
||||
}
|
||||
return assertObject;
|
||||
}
|
||||
|
||||
export function run() {
|
||||
notImplemented("test.run");
|
||||
|
@ -22,6 +56,10 @@ class NodeTestContext {
|
|||
this.#denoContext = t;
|
||||
}
|
||||
|
||||
get assert() {
|
||||
return getAssertObject();
|
||||
}
|
||||
|
||||
get signal() {
|
||||
notImplemented("test.TestContext.signal");
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue