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

Support usage of custom mocharc file #3

Open
gabrielthomasjacobs opened this issue May 4, 2021 · 4 comments
Open

Support usage of custom mocharc file #3

gabrielthomasjacobs opened this issue May 4, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@gabrielthomasjacobs
Copy link
Contributor

If custom mocharc files are supported, it would allow for a lot more flexibility in projects. It might also remove the need to explicitly support other cli options like reporter/reporter-options, as those could just be set in the config file.

Standard mocharc files are usually one of type: js, json, jsonc, yml, yaml.
mocharc.js requires using "type" = "module" in the package.json

some resources:
mocha config file documentations
mocha cli loadOptions documentation

I did some testing inside the test.html to determine if a config could be passed via something like:
mocha.setup({ "ui": "bdd", "config":"./mocharc.json" });
but it doesn't appear passing a config or options key is allowed here.

@larsthorup larsthorup added the enhancement New feature or request label May 4, 2021
@larsthorup
Copy link
Owner

This would be a great enhancement. The config will probably have to be split inside mocha-vite-puppeteer into two sets: one set for the mocha instance running in the browser (such as ui and timeout), and another set for mocha-vite-puppeteer itself (such as reporter and reporter options).

@gabrielthomasjacobs
Copy link
Contributor Author

Out of curiosity, if the reporter/reporter-options are configured via the mocharc.json and sent only to the mocha instance, would you expect the mocha instance to use it properly (e.g. create output files)?

If that's the case, would the config file need to be split so the cli knows what to output? e.g. when using reporter=dot

@larsthorup
Copy link
Owner

Well, no, that's not how it works. Check out the illustration at the bottom of the README.md: https://github.com/larsthorup/mocha-vite-puppeteer/

The mocha instance runs inside the browser and has no access to the file system or anything like that. Its only access to the outside world is via console.log() calls whose output are picked up by mocha-vite-puppeteer which can then perform any file-system related tasks on behalf of the mocha instance. This split is common to all test runners operating on real browsers. This is basically what makes this kind of tool a bit tricky to get right.

@gabrielthomasjacobs
Copy link
Contributor Author

Ah, I understand what you mean now. Thank you for the explanation!

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

No branches or pull requests

2 participants