Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@brettz9
Copy link
Contributor

@brettz9 brettz9 commented Nov 5, 2025

PR Checklist

Overview

Adds an ESM export file for use in the browser.

The other non-underscored (private) keys I saw on the global mocha object which I wasn't sure which I might include were the following:

files, options, suite, isWorker, throwError, ui

@mark-wiemer
Copy link
Member

For now let's exclude the private keys, they shouldn't be necessary for this export.

@mark-wiemer mark-wiemer self-assigned this Nov 8, 2025
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.57%. Comparing base (2a0bce0) to head (e913e02).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5527      +/-   ##
==========================================
- Coverage   93.69%   93.57%   -0.12%     
==========================================
  Files          57       57              
  Lines        4391     4465      +74     
  Branches      850      918      +68     
==========================================
+ Hits         4114     4178      +64     
- Misses        277      287      +10     

☔ 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.

@brettz9
Copy link
Contributor Author

brettz9 commented Nov 8, 2025

Thank you for the review!

I saw the linting failed after the merge, so I added my addition of /mocha.mjs to the eslint config file. There's also still a failure with /esm/mocha.js, a file that predated this PR, but with that file not being published, I wasn't sure what that was about. It technically is not even allowed with the ".js" extension since the package.json is type: 'commonjs'. Don't know if that file should be converted to .mjs, removed, treated as ESM by the linter anyways, or what?

@mark-wiemer
Copy link
Member

Fixed the build error, but not sure how to manually test this one. Going to unassign myself as this isn't a focus area for me compared to bugfixes and the v12 release, but hopefully after v12 we can come back to this. Thanks for getting this started and continuing to follow up!

@mark-wiemer mark-wiemer removed their assignment Nov 14, 2025
@mark-wiemer mark-wiemer self-assigned this Nov 22, 2025
@mark-wiemer
Copy link
Member

@JoshuaKGoldberg if you want to help me clean up PRs you can help review this one ;)

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

This looks good but I can't get it to work - is something missing?

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP or other posters - more information needed label Dec 18, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Confirmed this actually does work now. Great! ✨

Requesting changes to make it a little more informative if users mess this up. IME forgetting to run mocha.setup("bdd") (or running it out of order) is pretty easy to do.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Looks great to me, thanks! Bouncing back to @mark-wiemer for re-review as it's changed since Mark's last review.

At some point I think we'll want to revamp the browser-testing docs. But they're already pretty out of date separately from this, and will be captured by general docs cleanups.

@JoshuaKGoldberg JoshuaKGoldberg removed the status: waiting for author waiting on response from OP or other posters - more information needed label Dec 19, 2025
@mark-wiemer mark-wiemer merged commit e1cf23c into mochajs:main Dec 19, 2025
79 of 80 checks passed
@mark-wiemer
Copy link
Member

Created #5578. Thanks for the PR, @brettz9 !

sam-super added a commit to sam-super/mocha that referenced this pull request Dec 19, 2025
…-mod-not-found

* 'ts-mod-not-found' of github.com:sam-super/mocha:
  feat: add mocha.mjs export (mochajs#5527)
  docs: bumped docs-next Astro to ^5.16.6 (mochajs#5574)
  build(dev-deps): upgrade `markdownlint-cli` to latest v0.46.0  (mochajs#5560)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Ability to import mocha from ESM in the browser

3 participants