-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Feature Request Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faq
label, but none matched my issue. - I want to provide a PR to resolve this
Overview
I think support .only
in parallel mode would be a big win for developer experience when using mocha.
It makes total sense as to why it's not currently supported:
in parallel mode, Mocha does not load all files and suites into memory before running tests
I have checked for an existing issue (i expected to find one, so apologies if i missed it):
https://github.com/mochajs/mocha/issues?q=parallel%20only%20in%3Atitle
Suggested Solution
If we can support it, I'm thinking that something like a preloadTestFiles: true
config option could enable this. Having test files loaded in the main/parent thread would allow us to filter the test files that don't have .only
tests in them (assuming at least 1 .only
is found). This method would make the new functionality opt-in and avoid unexpected side effects from loading each test file in the main thread.
If someone could indicate if there is any appetite for this change then i'm willing to give creating a PR for it a go (although as a disclaimer it might be too much of a fundamental change, given my limited experience working in the mocha codebase).
Alternatives
as currently suggested in the docs users can add --grep <testname>
instead of .only
or --parallel=false
but this make the process quite clunky and un-intuitive (esp for people used to using jest).
Additional Info
No response