mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7c6682957b
This commit allows tests in the test runner to mock functions and methods. PR-URL: https://github.com/nodejs/node/pull/45326 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
34 lines
688 B
JavaScript
34 lines
688 B
JavaScript
'use strict';
|
|
const { ObjectAssign, ObjectDefineProperty } = primordials;
|
|
const { test, describe, it, 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,
|
|
it,
|
|
run,
|
|
test,
|
|
});
|
|
|
|
let lazyMock;
|
|
|
|
ObjectDefineProperty(module.exports, 'mock', {
|
|
__proto__: null,
|
|
configurable: true,
|
|
enumerable: true,
|
|
get() {
|
|
if (lazyMock === undefined) {
|
|
const { MockTracker } = require('internal/test_runner/mock');
|
|
|
|
lazyMock = new MockTracker();
|
|
}
|
|
|
|
return lazyMock;
|
|
},
|
|
});
|