Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: --ui require for require interface #2210

Closed
jmm opened this issue Apr 14, 2016 · 5 comments
Closed

🚀 Feature: --ui require for require interface #2210

jmm opened this issue Apr 14, 2016 · 5 comments
Labels
type: feature enhancement proposal

Comments

@jmm
Copy link

jmm commented Apr 14, 2016

There seems to be quite a bit of discussion about how to handle globals in future versions of Mocha, e.g. #1969. It seems like that stuff is going to be slow to hash out. In the meantime I'd like to suggest that you consider making it possible to do mocha --ui require to signal that you want the require interface -- meaning that you don't want globals defined. To me the current system is a half measure -- if you want to avoid using globals what you really want is to avoid them being defined at all to eliminate pollution of the global namespace and a source of potential bugs. To me it's very odd that "using" the require interface still requires using one of the other interfaces, which by default is bdd which defines globals.

@drazisil drazisil added the type: feature enhancement proposal label Mar 30, 2017
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Dec 27, 2023

that stuff is going to be slow to hash out

...yes 😄. require is becoming less of a common practice over time in modern JS code. ESM is taking over. Closing this as aged away.

If anybody has a really compelling use case for continuing to require with Mocha, please do file a new issue with details. Thanks!

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title --ui require for require interface 🚀 Feature: --ui require for require interface Dec 27, 2023
@lo1tuma
Copy link

lo1tuma commented Aug 23, 2024

If anybody has a really compelling use case for continuing to require with Mocha, please do file a new issue with details. Thanks!

I’m not sure if there is a misunderstanding here. If I understand the request correctly it is about the require interface from mocha as an alternative to e.g. bdd. It is not about supporting commonjs or not. Mochas require interface also works with ESM. So ideally the interface should be renamed, but that is a different topic.

Right now it is not possible to define the require interface via --ui so one of the other interfaces has to be used, if non is chosen the default bdd will apply. The reason for picking the require interface is to avoid the globals from mocha. So the request here is that when explicitly setting --ui require mocha doesn’t set any global variables und functions like describe or it can be only accessed when requiring them or importing them.

Related:

@JoshuaKGoldberg
Copy link
Member

We're talking about https://mochajs.org/#require, right?

If so: #956 would be the right tracking feature there. "require" as a term is what we're trying to avoid. A name like "import" or "esm" (just ideating) would be more forward-facing.

But, also note #5027: we're intentionally trying to change too many big things with Mocha.

@lo1tuma
Copy link

lo1tuma commented Aug 28, 2024

We're talking about https://mochajs.org/#require, right?

Yes, exactly.

If so: #956 would be the right tracking feature there.

Alright, I will add a comment there suggesting this feature as one way to opt-out of globals.

@JoshuaKGoldberg
Copy link
Member

Awesome thanks! FWIW I think I'm pretty in agreement with you, that having some equivalent to --ui require would be the right way to go long-term. @jest/globals was a nice step in Jest-land a bit back, and Vitest not enabling global by default is IMO a good thing (for them, without the long backwards compatibility story of Mocha).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

4 participants