Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

testing - Can I use Mocha's VS Code launch config settings from the command line?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...