Skip to content

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

Open
@JakobJingleheimer

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

Metadata

Metadata

Labels

test_runnerIssues and PRs related to the test runner subsystem.

Type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions