mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
Add options.exports support in mock.module() and normalize option shapes through a shared exports path. Keep defaultExport and namedExports as aliases, emit runtime deprecation warnings for legacy options, and update docs and tests, including output fixtures and coverage snapshots. Refs: https://github.com/nodejs/node/issues/58443 PR-URL: https://github.com/nodejs/node/pull/61727 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
18 lines
470 B
JavaScript
18 lines
470 B
JavaScript
import { describe, it, mock } from 'node:test';
|
|
|
|
describe('module test with mock', async () => {
|
|
mock.module('../coverage-with-mock/sum.js', {
|
|
exports: {
|
|
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(), {});
|
|
});
|
|
});
|