Skip to content

docs: switch util.inherits to class extends#5677

Open
JoshuaKGoldberg wants to merge 8 commits intomochajs:mainfrom
JoshuaKGoldberg:inherits-to-class-docs
Open

docs: switch util.inherits to class extends#5677
JoshuaKGoldberg wants to merge 8 commits intomochajs:mainfrom
JoshuaKGoldberg:inherits-to-class-docs

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

PR Checklist

Overview

Tweaks the page to mention extends instead of util.inherits.

Other parts of the page will need updating too. Out of scope for this.

🤎

@JoshuaKGoldberg JoshuaKGoldberg changed the title Inherits to class docs @JoshuaKGoldberg docs: switch util.inherits to class extends Feb 3, 2026
@JoshuaKGoldberg JoshuaKGoldberg changed the title @JoshuaKGoldberg docs: switch util.inherits to class extends docs: switch util.inherits to class extends Feb 3, 2026
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review February 3, 2026 15:38
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.40%. Comparing base (15fb31a) to head (5e31398).
⚠️ Report is 66 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5677      +/-   ##
==========================================
- Coverage   88.44%   88.40%   -0.04%     
==========================================
  Files          66       66              
  Lines        4794     4797       +3     
  Branches      978      982       +4     
==========================================
+ Hits         4240     4241       +1     
- Misses        554      556       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread docs-next/src/content/docs/explainers/third-party-reporters.mdx Outdated
@mark-wiemer
Copy link
Copy Markdown
Member

mark-wiemer commented Feb 14, 2026

@JoshuaKGoldberg as an FYI this will mean the docs slightly don't match our actual releases, not even a beta release for this change is ready. I'm OK to merge if you are, but maybe we should at least get a beta for this, or add a disclaimer? Esp. if folks are still using v11, for which we don't have dedicated docs yet. (e.g. v11.mochajs.org)

@mark-wiemer mark-wiemer added the status: blocked Waiting for something else to be resolved label Feb 21, 2026
@mark-wiemer
Copy link
Copy Markdown
Member

Blocked on a beta release first

@mark-wiemer mark-wiemer self-assigned this Mar 25, 2026
@mark-wiemer mark-wiemer removed the status: blocked Waiting for something else to be resolved label Mar 25, 2026
@mark-wiemer mark-wiemer added this to the Chores milestone Mar 25, 2026
@mark-wiemer mark-wiemer added the status: needs review a maintainer should (re-)review this pull request label Mar 25, 2026
@mark-wiemer
Copy link
Copy Markdown
Member

mark-wiemer commented Mar 25, 2026

I'll try to act as an end-user with Mocha 11 and see if this class ... extends syntax "just works" and it was always viable. If not, no worries, we will have a beta release soon I'm sure :) We should add the "new in Mocha 12" admonition if it doesn't work in Mocha 11, of course.

@mark-wiemer mark-wiemer self-requested a review March 25, 2026 14:10
mark-wiemer added a commit to mark-wiemer/hello-hello that referenced this pull request Apr 18, 2026
mark-wiemer added a commit to mark-wiemer/hello-hello that referenced this pull request Apr 18, 2026
mark-wiemer added a commit to mark-wiemer/hello-hello that referenced this pull request Apr 18, 2026
Accidentally overpasted

mochajs/mocha#5677
Copy link
Copy Markdown
Member

@mark-wiemer mark-wiemer left a comment

Choose a reason for hiding this comment

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

class MyReporter(runner) { isn't valid syntax, I don't think! Even when trying to revisit this, I couldn't get the new pattern to work, we'll have to revise this. Ref https://github.com/mark-wiemer/hello-hello/tree/496f4640638d717287601fc60b4ddb5d86d62abc/packages/mocha/packages/custom-reporter

@mark-wiemer mark-wiemer removed the status: needs review a maintainer should (re-)review this pull request label Apr 18, 2026
@JoshuaKGoldberg JoshuaKGoldberg added the status: blocked Waiting for something else to be resolved label Apr 29, 2026
@JoshuaKGoldberg
Copy link
Copy Markdown
Member Author

Confirmed on the failure:

 Exception during run: TypeError: Class constructor Base cannot be invoked without 'new'
    at new MyReporter (/Users/josh/repos/hello-hello/packages/mocha/packages/custom-reporter/my-old-reporter.cjs:5:24)
    at Mocha.run (/Users/josh/repos/hello-hello/packages/mocha/packages/custom-reporter/node_modules/mocha/lib/mocha.js:995:18)
    at singleRun (/Users/josh/repos/hello-hello/packages/mocha/packages/custom-reporter/node_modules/mocha/lib/cli/run-helpers.js:175:16)
    at async exports.handler (/Users/josh/repos/hello-hello/packages/mocha/packages/custom-reporter/node_modules/mocha/lib/cli/run.js:376:5)

Switching MyReporter to be an actual class fixes things:

class MyReporter extends mocha.reporters.Base {
  constructor(runner) {
    super(runner);
...
pass: add works
end: 1/1

@JoshuaKGoldberg JoshuaKGoldberg removed the status: blocked Waiting for something else to be resolved label Apr 29, 2026
@JoshuaKGoldberg JoshuaKGoldberg added the status: blocked Waiting for something else to be resolved label Apr 29, 2026
@mark-wiemer mark-wiemer removed the status: blocked Waiting for something else to be resolved label May 2, 2026
@mark-wiemer
Copy link
Copy Markdown
Member

@JoshuaKGoldberg I'll try to repro this shortly to make sure I fully understand stuff. In the meantime, let me know if you have ideas for how to draft a migration guide for this. We'll need one to close the backing issue :) Thanks for continuing this one!

@mark-wiemer mark-wiemer added the status: needs review a maintainer should (re-)review this pull request label May 2, 2026
@mark-wiemer mark-wiemer removed this from the Chores milestone May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs review a maintainer should (re-)review this pull request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants