node/lib/test.js
René 3b7477c4d5
Some checks failed
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-nix (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` with invalid message (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
V8 patch update / v8-update (push) Has been cancelled
OpenSSL update / openssl-update (push) Has been cancelled
Timezone update / timezone_update (push) Has been cancelled
test_runner: fix lazy test.assert accessor
PR-URL: https://github.com/nodejs/node/pull/61097
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Aviv Keller <me@aviv.sh>
2025-12-20 18:54:32 +00:00

80 lines
1.5 KiB
JavaScript

'use strict';
const {
ObjectAssign,
ObjectDefineProperty,
} = primordials;
const { test, suite, before, after, beforeEach, afterEach } = require('internal/test_runner/harness');
const { run } = require('internal/test_runner/runner');
module.exports = test;
ObjectAssign(module.exports, {
after,
afterEach,
before,
beforeEach,
describe: suite,
it: test,
run,
suite,
test,
});
let lazyMock;
ObjectDefineProperty(module.exports, 'mock', {
__proto__: null,
configurable: true,
enumerable: true,
get() {
if (lazyMock === undefined) {
const { MockTracker } = require('internal/test_runner/mock/mock');
lazyMock = new MockTracker();
}
return lazyMock;
},
});
let lazySnapshot;
ObjectDefineProperty(module.exports, 'snapshot', {
__proto__: null,
configurable: true,
enumerable: true,
get() {
if (lazySnapshot === undefined) {
const {
setDefaultSnapshotSerializers,
setResolveSnapshotPath,
} = require('internal/test_runner/snapshot');
lazySnapshot = {
__proto__: null,
setDefaultSnapshotSerializers,
setResolveSnapshotPath,
};
}
return lazySnapshot;
},
});
let lazyAssert;
ObjectDefineProperty(module.exports, 'assert', {
__proto__: null,
configurable: true,
enumerable: true,
get() {
if (lazyAssert === undefined) {
const { register } = require('internal/test_runner/assert');
lazyAssert = { __proto__: null, register };
}
return lazyAssert;
},
});