-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Mocha.utils.lookupFiles is no longer available #4398
Comments
Yes, it was moved to lib/cli/lookup-files.js in order to exclude it from our browser build. @types/mocha: is not maintained by us. We don't have resources to offer our own version of TypeScript type definitions. |
The only place we have found this exposed is in const lookupFiles = require('mocha/lib/cli/lookup-files'); |
No, I don't think so, must be correct. I'm not convinced of exporting it somewhere else for greater visibilty. We use this function only in CLI context and need to keep it out of our browser bundle. The API documentation is incomplete, I can't find |
That makes sense that it is generally only used in the CLI context. However, I feel that a like I know running a testing framework isn't the primary method of using them (In our case our tests must be run inside of serverless infrastructure), so if mocha isn't intended to be run programmatically (or doesn't officially support that) I understand, and it would be great to see a line about that in the documentation. On the other hand, if calling mocha programmatically is supported, then this is my request to expose Regardless, thank you so much for maintaining this library. I truly appreciate your swift and candid responses. |
I agree with @auroq's opinion. |
Either way, since
The Node.js-specific public APIs we have are very few:
For the sake of ergonomics, I think it makes sense to alias these in const {lookupFiles, loadRc, loadPkgRc, loadOptions} = require('mocha/lib/cli'); We can make this a little easier to use with subpath exports, (e.g., aliasing |
fixes #4398 - fixes API documentation for all of these (and `module:lib/cli.main`) via JSDoc aliasing - aliases `lib/cli/cli.js` to `module:lib/cli`; `module:lib/cli/cli` is no longer a thing - the `lib/cli/options.js` and `lib/cli/lookup-files.js` _modules_ (not necessarily their _contents_) are now private example usage: ```js const {loadRc, loadPkgRc, loadOptions, lookupFiles} = require('mocha/lib/cli'); ```
See #4419 for changes regarding this |
Does lookupfiles really need to be a public API? I know we accidentally made a breaking change here, and that's very unfortunate. But really all that lookupfiles is, is a glob function. There are myriads of implementations of glob to take off the shelf. Why does mocha need to maintain another one as a public API? |
I think a proper public API for running mocha programmatically is what's missing here.
It was a public API in the sense that it was documented in API docs. Personally, I don't like a big API surface, since it's hard to maintain (hence this issue). It's better to have a smaller one (as discussed in #3882) and then have proper integration tests for them. Maybe it's good to combine these thoughts into a new issue? I'd be happy to do so. I'm a consumer of the API myself and thus share the "pain". I would like to focus on that whenever I'm done with my current priority (sorry). Hopefully within a month or so. |
I mean I would like to know from @auroq and/or @MoonSupport if they need Here's a naive search for usages of That said, personally, I can tolerate absorbing the maintenance burden of I think what we need to do before considering merging #4419 is to un-break Mocha v8.1.0 with another patch release which restores the original path to |
actually maybe it makes more sense to just add that to #4419, so I can reference the new location. |
fixes #4398 - fixes API documentation for all of these (and `module:lib/cli.main`) via JSDoc aliasing - aliases `lib/cli/cli.js` to `module:lib/cli`; `module:lib/cli/cli` is no longer a thing - the `lib/cli/options.js` and `lib/cli/lookup-files.js` _modules_ (not necessarily their _contents_) are now private example usage: ```js const {loadRc, loadPkgRc, loadOptions, lookupFiles} = require('mocha/lib/cli'); ```
The commit linked below migrated
lookupFiles
from utils to cli. This caused it to be removed fromMocha.utils.lookupFiles
, and it appears that it is no longer accessible anywhere.This was still exposed as of 8.0.1 but is no longer available as of 8.1.1.
Additionally,
Mocha.utils.lookupFiles
does still appear in the current version of@types/mocha
.We are using this when calling
mocha.run
programatically.This is the call we are making to
lookupFiles
40f951b#diff-50e3aa130a4f97a42ee2cf111c7b1d9d
The text was updated successfully, but these errors were encountered: