Search code examples
node.jstestingautomated-testsmocha.jssuperagent

How to run test with local.example.js ENV


I have 2 env:

i run test with this command "mocha specs/* --opts ./mocha.opts" and default run dev ENV. What command I can use for a run with local.example.js ENV ?

Like "mocha specs/* --opts ./mocha.opts --env local.example.js"


Solution

  • If you are using mocha version 6+, you might consider defining configuration in a *.js file instead of legacy *.opts file.

    Then you will be able to run mocha tests with

    $ mocha specs/* --config path/to/config.js
    

    More information here: https://mochajs.org/#-config-path