mochapack
mochapack copied to clipboard
Ability to use a mocharc config file.
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!
@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)
@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
@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
@lakeshadow0 Have you tried it with the config flag pointing to your .mocharc?
@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.
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.