-
-
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: Expose PluginLoader
or handleRequires
to have other frameworks provide support for the require
option
#4961
Comments
@christian-bromann Mocha's |
@juergba thanks for getting back. The PR currently imports
I think to make the Mocha integration work it would be great to either export |
@christian-bromann yes, it's possible. I'm unsure which way to go wether
Evtl. you can explain your reasons for choosing the latter way. |
@christian-bromann I think this is still waiting on you: can you explain why you chose We the new maintainers are still ramping up (#5027) and this is a relatively niche use case (API request for large API user), so it might be a while before we have the time to deeply understand this on our own. Any help you can give us & context on why you implemented things the way you did would be very helpful. 🙂 Thanks! |
PluginLoader
or handleRequires
to have other frameworks provide support for the require
optionPluginLoader
or handleRequires
to have other frameworks provide support for the require
option
Hey @JoshuaKGoldberg , I could use the PluginLoader but would need to re-implement all the other logic within // @ts-expect-error not exposed from package yet, see https://github.com/mochajs/mocha/issues/4961
import { handleRequires } from 'mocha/lib/cli/run-helpers.js' which works but is not ideal. |
Got it, thanks. I took a read through the code and it looks pretty reasonable what wdio is doing: using Mocha's
async function handleRequires(requires = [], { ignoredPlugins = [] } = {}) {
const pluginLoader = PluginLoader.create({ ignore: ignoredPlugins });
for await (const mod of requires) {
let modpath = mod;
if (fs.existsSync(mod) || fs.existsSync(`${mod}.js`)) {
modpath = path.resolve(mod);
}
const requiredModule = await requireOrImport(modpath);
if (requiredModule && typeof requiredModule === "object") {
pluginLoader.load(requiredModule);
}
}
return await pluginLoader.finalize();
} Per #4961 (comment):
I think it'd make most sense to provide Note also that #1457 discusses a separate concept of a "Plugin API", which is a kind of unfortunate naming conflict. One of the two will need to be renamed. No thoughts yet on which. cc @mochajs/maintenance-crew as this would be a big new API piece - thoughts? |
Is your feature request related to a problem or a nice-to-have?? Please describe.
For frameworks such as WebdriverIO that integrate Mocha, it would be great to support the
require
option.Describe the solution you'd like
For that to happen, Mocha should export the
PluginLoader
or have thehandleRequires
exposed from the package.Describe alternatives you've considered
None.
Additional context
Issue filed in the WebdriverIO project: webdriverio/webdriverio#9490
The text was updated successfully, but these errors were encountered: