Search code examples
webstormnconf

WebStorm configure Mocha to accept command line options


WebStorm Run-'Edit Configuration' is set up to run Mocha test.

The Mocha Javascript test code accepts nconf command line arguments for e.g. --user='production'

How can 'Edit Configuration' for Mocha test be set up to accept the nconf command line argument?


Solution

  • You can use Extra Mocha Options field for this:

    enter image description here

    Works fine for me when using the following code:

    var nconf = require('nconf');
    nconf.argv();
    
    describe("Numbers", function () {
            var foo, json;
    
            beforeEach(function(){
                foo = nconf.get('foo');
                 ...