Skip to content

mock.module: consolidate defaultExport + namedExports into exports #58443

Description

@JakobJingleheimer

Currently, mock.module's options expects defaultExport and namedExports separately. We are not aware of a reason to separate them, and it's inconsistent with other major testing frameworks/utilities (such as Jest).

function mock__default() {…}
function mock__foo() {…}

mock.module('example.mjs', {
-  defaultExport: mock__default,
-  namedExports: {
+  exports: {
+    default: mock__default,
     foo: mock__foo,
   },
});

The plan would be:

  1. Immediately introduce options.exports
    • alias defaultExport & namedExports into options.exports
  2. Immediately flag defaultExport & namedExports deprecated
  3. Provide a userland-migration to automatically transform old to new
  4. In node 25.x remove defaultExport & namedExports

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.test_runnerIssues and PRs related to the test runner subsystem.

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions