mocha-parallel / mocha-parallel-tests

Parallel test runner for mocha tests. Looking for maintainer.
MIT License
200 stars 45 forks source link

Support new Mocha config file #285

Open Lakitna opened 4 years ago

Lakitna commented 4 years ago

I really like the new Mocha config files. I've fully switched over to them from mocha.opts. I also use the --config flag to split my e2e test config from my unit test config.

Both config file resolution and the --config flag do not work at the moment. Well, to be more precise, some config is picked up and others are not.

So I took a look at the code. It seems like this might be the only option that is not super simple to implement. It seems like we could pass the resolved config file to MochaWrapper here https://github.com/mocha-parallel/mocha-parallel-tests/blob/master/src/bin/cli.ts#L53. However, this would mean that the custom config logic needed for parallel stuff is bypassed.

Do we have to add each config item to process.argv instead, like what's happening with the old mocha.opts file? https://github.com/mocha-parallel/mocha-parallel-tests/blob/master/src/bin/cli.ts#L45 That approach feels iffy for the new config files though.

I'm willing to implement this but I'm not sure how to approach this since I'm not very well versed in this code or using Mocha programmatically. For my tests right now I'll try to find a workaround.

1999 commented 4 years ago

New config files look great for sure. Seems like they are replacement for mocha.opts, right?

Do we have to add each config item to process.argv instead, like what's happening with the old mocha.opts file

I don't think we do this now. The link you posted is about the CLI for the main process. I guess the logic should be somewhat close to the existing logic: https://github.com/mocha-parallel/mocha-parallel-tests/blob/master/src/bin/cli.ts#L130

Also, does --config option take precedence over mocha.opts file?

xenoterracide commented 4 years ago

I think this is my problem

Calebs-MBP:aurelia-propertysource calebcushing$ npx mocha-parallel-tests
No test files found
Calebs-MBP:aurelia-propertysource calebcushing$ npx mocha

  value
    ✓ simple property

  1 passing (45ms)

Calebs-MBP:aurelia-propertysource calebcushing$ mocha --version
bash: mocha: command not found
Calebs-MBP:aurelia-propertysource calebcushing$ npx mocha --version
7.1.1
Calebs-MBP:aurelia-propertysource calebcushing$ npx mocha-parallel-tests --version
2.3.0

mocha.opts file support is DEPRECATED and will be removed from a future version of Mocha. We recommend using a configuration file instead.

https://mochajs.org/#mochaopts

here's the documentation for the precedence of files https://mochajs.org/#configuring-mocha-nodejs