Fixes: https://github.com/nodejs/node/issues/59112 PR-URL: https://github.com/nodejs/node/pull/59348 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
17 lines
475 B
JavaScript
17 lines
475 B
JavaScript
import { describe, it, mock } from 'node:test';
|
|
|
|
describe('module test with mock', async () => {
|
|
mock.module('../coverage-with-mock/sum.js', {
|
|
namedExports: {
|
|
sum: (a, b) => 1,
|
|
getData: () => ({}),
|
|
},
|
|
});
|
|
|
|
const { theModuleSum, theModuleGetData } = await import('../coverage-with-mock/module.js');
|
|
|
|
it('tests correct thing', (t) => {
|
|
t.assert.strictEqual(theModuleSum(1, 2), 1);
|
|
t.assert.deepStrictEqual(theModuleGetData(), {});
|
|
});
|
|
});
|