Mock Module Exports
This migration trasforming use of deprecated options.defaultExport and options.namedExports on
node:test.mock
Example
diff
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Handle mock.module exports deprecation
npx codemod @nodejs/mock-module-exports
This migration trasforming use of deprecated options.defaultExport and options.namedExports on
node:test.mock
diff
This is one example from the codemod's test cases. The codemod may handle many more cases.
Build your own codemod and share it with the community.
1 import { mock } from 'node:test';
2
3 const mockValues = {
4 defaultExport: 'bar',
5 namedExports: {
6 foo: 'foo',
7 },
8 }
9
10 mock.module('example', mockValues);
11