mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.6k stars 3.01k forks source link

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

Open brettz9 opened 2 months ago

brettz9 commented 2 months ago

Feature Request Checklist

Overview

Inability to import as ESM module from the browser

Suggested Solution

Include an ESM build

Alternatives

Use Rollup on the file but burdensome for each project. Continue adding separate script tags for Mocha and other projects.

Additional Info

No response

JoshuaKGoldberg commented 2 months ago

Inability to import as ESM module from the browser

Could you post a reproduction, please? Mocha does have both ESM and browser support, in theory. But both of those terms are pretty vague without more context.

🚀 Feature:

...and don't forget to fill out the title 🙂

brettz9 commented 2 months ago

Whoops... :-) Here. This doesn't work: https://github.com/brettz9/mocha-no-esm-minimal-test-repro

JoshuaKGoldberg commented 1 month ago

👍 makes sense to me. I see no reason why we wouldn't want to enable a proper import for Mocha rather than relying on a global. Heck, I'd probably encourage users to use the import!