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

Ability to use a mocharc config file. #9

Open
jamesopti opened this issue Mar 8, 2019 · 6 comments
Open

Ability to use a mocharc config file. #9

jamesopti opened this issue Mar 8, 2019 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jamesopti
Copy link

Is there any support for using a mocharc file instead of mochapack.opts?

As of Mocha 6, mocha.opts is considered legacy and I find it easier to specify multiple configs in JSON instead of as command line arguments.

P.S. - Thanks for picking up support for this package!

@larixer larixer added enhancement New feature or request good first issue Good for newcomers labels Mar 9, 2019
@kierans
Copy link

kierans commented Feb 11, 2020

@jamesopti Finding this issue helped me stop pulling my hair out!

However I'm not having success with a mocha.opts with a --require flag in it. Where should the mocha.opts go in your source tree? What's the best way to --require a file from the source tree eg:

--require ../../src/globals

(importing the module in the test file works, but I want to move the require to the mocha.opts)

@Jack-Barry
Copy link

@jamesopti or @kierans can you give this a go with 2.0.0? If it works and you do not run into the issue opened in #65 then we can mark this as resolved.

Thanks

@lakeshadow0
Copy link

lakeshadow0 commented Jul 29, 2020

@Jack-Barry I am using 2.0.2 and my .mocharc.yaml is not being honored in any fashion. Are only specific file formats supported?

edit: tried with .json and it did not work either

@Jack-Barry
Copy link

Jack-Barry commented Jul 29, 2020

@lakeshadow0 Have you tried it with the config flag pointing to your .mocharc?

@lakeshadow0
Copy link

lakeshadow0 commented Jul 29, 2020

@Jack-Barry Ah, I see. I just tried it, and got the error Invalid JSON config file: .mocharc.yaml. I assume then only JSON configurations are supported.

edit: after converting to JSON everything works except for "spec" configuration was not honored. I would expect that YAML would be supported since mocha supports it. I can offer some time to help out with regards to this if you could just point me in the right direction.

@Jack-Barry
Copy link

There might be something out of whack with src/cli/argsParser/optionsFromParsedArgs/mocha/mochaOptionsFromParsedArgs.ts or src/cli/argsParser/optionsFromParsedArgs/mocha/mergeMochaConfigWithOptions.ts

Basically, Mochapack is aiming to offload as much functionality as possible to Mocha, might have missed something in here as far as extracting the config file/determining which parser to use under the hood by Mocha's internals.

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

No branches or pull requests

5 participants