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 new Mocha config file #285

Open
Lakitna opened this issue Apr 3, 2020 · 2 comments
Open

Support new Mocha config file #285

Lakitna opened this issue Apr 3, 2020 · 2 comments

Comments

@Lakitna
Copy link

Lakitna commented Apr 3, 2020

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
Copy link
Collaborator

1999 commented Apr 8, 2020

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
Copy link

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

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

No branches or pull requests

3 participants