I have a Mocha.JS test suite written using the Visual Studio Code IDE, which includes a launch configuration describing all the parameters and environment settings I need. This works well when running inside VSCode, but I'd like to be able to run exactly the same tests from the command line using just an npm test
command or similar.
I'd like both approaches to use the settings from a single place.
I have tried copying the args
and env
elements to the package.json file under a new mocha
heading, which is supposed to be supported. However, this led to an Error: Not enough arguments following: reporter-options
error being shown.
My current config in VSCode's launch.json is:
"args": [
"-u","bdd",
"--timeout","999999",
"--colors",
"--reporter","mochawesome",
"--reporter-options", "reportDir=reports,reportFilename=Tests,timestamp=yyyymmdd-HHMM",
"${workspaceFolder}/test/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node",
"env": {
"PWDEBUG": "1",
"SERVER_URL": "http://some-server"
}
question from:
https://stackoverflow.com/questions/65849815/can-i-use-mochas-vs-code-launch-config-settings-from-the-command-line 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…