Skip to content

chore: Fix mocha in Node v22+ - #4629

Merged
rschristian merged 1 commit into
mainfrom
chore/node-22
Feb 17, 2025
Merged

rschristian merged 1 commit into
mainfrom
chore/node-22

Conversation

@rschristian

Copy link
Copy Markdown
Member

Just quick fix (that we don't need quite yet) as I noticed it.

Mocha seemingly requires an explicit "type": "commonjs" as of Node 22+, perhaps because of the new require(esm) that landed? Not quite sure.

This fixes it, in lieu of Mocha fixing something upstream (which they very well might do yet).

@coveralls

coveralls commented Jan 10, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 99.618%. remained the same
when pulling f1fcf61 on chore/node-22
into 2812165 on main.

@rschristian
rschristian marked this pull request as ready for review February 17, 2025 01:55
@rschristian

Copy link
Copy Markdown
Member Author

As best as I can tell, this is a change in how Node tries to determine module types.

Whereas in the past CJS was assumed here, Node now begins to read the file and guesses that this is meant to be ESM once it sees those import statements. As it's not CJS, the require hook doesn't get called and Node then fails to parse the module due to the JSX we have within.

As this is meant to be the assumed/default value, I'm really hoping nothing breaks here.

@rschristian
rschristian merged commit 5aa7244 into main Feb 17, 2025
@rschristian
rschristian deleted the chore/node-22 branch February 17, 2025 02:00
@JoviDeCroock JoviDeCroock mentioned this pull request Feb 18, 2025
This was referenced Feb 18, 2025
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.

4 participants