Skip to content

feat(blog): add mocha-to-node-test-runner migration guide - #9088

Closed
Xstoudi wants to merge 3 commits into
nodejs:mainfrom
Xstoudi:feature/blog-post-mocha-migration
Closed

feat(blog): add mocha-to-node-test-runner migration guide#9088
Xstoudi wants to merge 3 commits into
nodejs:mainfrom
Xstoudi:feature/blog-post-mocha-migration

Conversation

@Xstoudi

@Xstoudi Xstoudi commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

As titles

Related Issues

No related issue

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodejs-org Ready Ready Preview Aug 9, 2026 6:28pm

Request Review

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Documentation-only addition with no application or runtime code changes.

Overview
Adds a new migrations blog post at mocha-to-node-test-runner.mdx documenting the @nodejs/mocha-to-node-test-runner codemod.

The article explains why teams might switch from Mocha to the built-in runner, Node.js ≥18 requirements (and major-version/engine bumps when dropping older Node), which APIs the codemod rewrites (describe/it, hooks, .skip/.only, this.timeout), and how to run it via npx codemod plus switching package.json scripts to node --test. It includes diff-style examples, notes on unsupported Mocha features, and a short recognition of the Mocha project.

Reviewed by Cursor Bugbot for commit ea97e4c. Bugbot is set up for automated code reviews on this repo. Configure here.

@AugustinMauroy

Copy link
Copy Markdown
Member

@nodejs/web-infra what is the Vercel issue ?

@avivkeller

Copy link
Copy Markdown
Member

@Xstoudi Your PR head is outdate with main, please rebase (it'll fix Vercel)

Comment thread apps/site/pages/en/blog/migrations/mocha-to-node-test-runner.mdx Outdated
Comment on lines +20 to +26
## Node.js Version Requirements

- Node.js v18.0.0 or later (Node.js test runner is available but marked experimental)
- Node.js v20.0.0 or later (Node.js test runner is stable)

> If your package currently supports Node.js versions earlier than v18.0.0, you cannot migrate to the Node.js test runner without dropping support for those versions.
> This requires bumping the major version of your package AND updating the engines field in your package.json to require Node.js >= v18.0.0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This section isn't needed, since those versions are both EOL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

humm IMO we should keep it because user may have older codebase that use EoL and to update it they can use this codemod.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's common for migrations to run to update outdated software in outdated environments.
Knowing that this migration won't work before node 20 -18 with experimental flag- would be valuable to me tbh. I can maybe agree that lines 25 and 26 are not that useful tho.

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blocking for further discussion

@Xstoudi

Xstoudi commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Looks like the further discussion isn't happening on this PR yet is blocking it. Not a big fan of that.

@Xstoudi Xstoudi closed this Aug 9, 2026
@MattIPv4

MattIPv4 commented Aug 9, 2026

Copy link
Copy Markdown
Member

Looks like the further discussion isn't happening on this PR yet is blocking it. Not a big fan of that.

It's happening in nodejs-website on Slack 👍 It is quite often easier to have conversations there and then report back on a PR once a decision has been made, rather than trying to have a conversation on the PR itself.

@avivkeller

Copy link
Copy Markdown
Member

Hi @Xstoudi! We've reached a decision, and. have moved this content to https://nodejs.org/learn/userland-migrations/mocha-to-node-test-runner

@Xstoudi

Xstoudi commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

What a wonderful example of consensus seeking :)

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