question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

I am confused as to how to use mochapack v2.0.0. Any doc would be useful on how to pass the config, and what config options are available. Previously, I used mochapack.opts file and provided the same as cli args -

mochapack --opts test/mochapack.opts

The file contents include

--require "@babel/register"
--require "jsdom-global/register"
--require "test/setup.js"
--recursive
"src/**/test/**/*.spec.js" "src/**/*.vue"
--reporter "spec"
--webpack-config test/webpack.config.js

Now, if I run the same way I get exception - WebpackOptionsValidationError: Invalid configuration object.

Tried with

mochapack --webpack-config test/webpack.config.js

Now, webpack config is loaded properly, but how/where do you specify my root .mocharc.json file. Contents are below -

{
  "extension": ["js", "vue"],
  "require": ["@babel/register", "jsdom-global/register", "test/setup.js"],
  "reporter": "spec",
  "spec": ["src/**/test/**/*.spec.js", "src/**/*.vue"],
  "recursive": true
}

The problem with mocharc.json file in root folder - No tests are running.

@Jack-Barry -> Thanks for all your help!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dsrini-opencommented, May 25, 2020

Resolved the issue by passing the following config in package.json scripts under test - NODE_ENV=test mochapack --config .mocharc.json --webpack-config test/webpack.config.js \"src/**/test/**/*.spec.js\"

I had to pass the location of mocha config file and webpack config file with the glob to run the tests. Now, the mocha config file contains --require scripts.

Like I stated, some doc/info (in README) on how to pass the config would be helpful. Yet to figure, if we could have all the args in a mochapack config file, or what the file name would be etc…

0reactions
thom-niccommented, Jul 17, 2020

I ran into this issue as well. --opts is not handled properly with mocha v7 nor does it pick up the default .mocharc.js when running through mochapack. But passing --config .mocharc.js --webpack-config ____ got it to work.

± npm ls mochapack mocha
├── mocha@7.2.0 
└── mochapack@2.0.3 
Read more comments on GitHub >

github_iconTop Results From Across the Web

HuskyCrates v2.0.0 Configuration Basics - YouTube
HuskyCrates v2. 0.0 Configuration Basics. 5.2K views 4 years ago. codeHusky. codeHusky. 8.37K subscribers. Join. Subscribe. 41. I like this.
Read more >
Migrating to v2.0.0 - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Release notes v2.0.0 - ProGlove Documentation
Release notes v2.0.0 ... This section presents the features introduced or enhanced in the Gateway v2.0.0 release. Remote Config. Full support for the...
Read more >
Homestead v2.0.0 configuration - gists · GitHub
Homestead v2.0.0 configuration. GitHub Gist: instantly share code, notes, and snippets.
Read more >
CFB config issue NCS V2.0.0 - Nordic Q&A
Hi, I am trying to compile the cfb sample as provided in v2.0.0. /opt/nordic/ncs/v2.0.0/zephyr/samples/subsys/display/cfb my overlay file is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found