Skip to content

Add recipe mock-module-exports#390

Open
brunocroh wants to merge 15 commits intonodejs:mainfrom
brunocroh:test-runner-defaultExport-to-default
Open

Add recipe mock-module-exports#390
brunocroh wants to merge 15 commits intonodejs:mainfrom
brunocroh:test-runner-defaultExport-to-default

Conversation

@brunocroh
Copy link
Member

@brunocroh brunocroh commented Mar 3, 2026

add recipe to handle deprecated options.defaultExport and options.namedExports on
node:test.mock add into

Example

mock.module('…', {
-   defaultExport: …,
-   namedExports: {
-   	foo: …
-   },
+   exports: {
+   	default: …,
+   	foo: …,
+   },
});

ref: nodejs/node#61727

@brunocroh brunocroh self-assigned this Mar 3, 2026
@brunocroh brunocroh marked this pull request as ready for review March 14, 2026 22:49
@brunocroh brunocroh requested a review from a team March 14, 2026 23:07
@brunocroh brunocroh changed the title feat: add mock-module-exports Add recipe mock-module-exports Mar 14, 2026
Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the unshift vs push thing, LGTM! 🙌

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there are a release note/docs link to add as references here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only resource for now is the PR: nodejs/node#61727

The idea is that we release the deprecation with this codemod, so I think the deprecation hasn’t been added to the docs yet, but I could be wrong.

Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for the tidy. Did you see the bit about unshift vs push?

@brunocroh
Copy link
Member Author

Cool, thanks for the tidy. Did you see the bit about unshift vs push?

I did a small research and tried using push and shift. That would cause the same result as unshift and pop, since the entire array still needs to be moved on shift or unshift.

The possible solutions I thought of were:

  • Trying to achieve the same behavior without removing items from the array by using a for loop with a pointer.

  • Creating a custom queue class implemented with a linked list.

I think the best approach would be the for loop with a pointer, but let me know if you have a better idea.

Co-authored-by: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants