-
-
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
🚀 Feature: Public equivalent(s) to loadOptions and handleFiles API(s) #3882
Comments
I'm noticing that |
@nicojs refering
|
Hi @juergba thanks for your reply ☕️ It's fine to change the implementation details, as long as the API stays the same. We ideally want to load the exact same options as mocha would have, so fixing bugs, loading from different sources, etc is all fine. There is one change I would like for this function. The first line is I would be happy to open a PR for this. I would ofcourse update the docs and add a unit test for it as well. Shall I open up another issue for the |
@nicojs Just opening some PR's would probably lead to nowhere, I guess. At least at the moment. Our @boneskull cc |
Well that's why we're discussing it here, aren't we? 😅 The more fundamental question is: do you want to support the use of Mocha as a library? We would like to build an awesome experience in Stryker for mocha, but we need some help (although we're willing to do the work).
I don't really understand this point. Allowing developers using the mocha library to pass along parsed options won't really hinder normal cli use of mocha. I also have trouble understanding that |
That is your subjective point of view. I personally try to weight issues according to (Mocha's/my subjective) priorities and also per my personal know-how / interest. I think you have already merged the feature in question into your repo. So you have found a way to achieve this. My personal opinion may not represent Mocha's opinion, maybe other members will join the discussion. |
Hi again. It seems that a recent change in Mocha broke our stryker plugin for mocha. For more info see this: stryker-mutator/stryker-js#1693 I would still love for mocha to provide a public api to load options and find files. This is really preventing plugin creators to use Mocha programmatically 😥 |
@boneskull what are you're thoughts on this? Would you allow me to write a PR for this? |
Same goes for handleRequires |
Propose something... unsure if just calling the API "public" is what we should be doing. When you do, please show an example use-case. |
Thanks for pitching in, @boneskull . I agree that making internal stuff in I think the goal is to be able to mimic the mocha cli, but override certain things. This is what Stryker is doing. I think this is also what @jan-molak is looking for. An example: const { createMocha, loadOptions } = require('mocha');
const options = await loadOptions();
// Change options, for example:
options.require.push('my-plugin');
options.reporter = myReporter;
options.parallel = false;
// Now create a mocha instance,
// this will do all nessesary things to load and initialize a mocha instance.
// For example: `handleRequire`, `loadRootHooks` and `collectFiles`.
const mocha = await createMocha(options);
// Now we can still override stuff before a run. For example:
mocha.cleanReferencesAfterRun(false);
// And now decide to run
mocha.run(); If you agree, I can implement it and rewrite some of the bits in the |
This is what needed to change for Stryker to support mocha 8's rootHooks, while importing from the semi-private https://github.com/stryker-mutator/stryker/pull/2259/files @boneskull Would it be OK if I took a shot at my proposal above? |
something like this, but try to avoid adding node-specific stuff to the default exports. this doesn’t seem applicable to the browser |
@JoshuaKGoldberg I'm still interested in this issue. We are currently depending on these private API's 😅😓😥 loadOptions
collectFiles
handleRequires
loadRootHooks |
Congrats on the release of version 6. The code cleaned up nicely and the new config files are a big bonus ☕️. I also love the extended api documentation.
We want to support the loading of config files as well in the Stryker mocha runner. My question is: can we rely on the
require('mocha/lib/cli/options').loadOptions
to load options? Or is it subject to change without a major release? It is documented here: https://mochajs.org/api/module-lib_cli_options.html#.loadOptions, so I would assume that changes to this would be major.EDIT:
Just as important for us is the
collect-files method. That one cannot be found in the api docs (yet). Could we make that api public as well?handleFiles
The text was updated successfully, but these errors were encountered: