vendredi 22 janvier 2021

Use Mocha's Visual Studio Code launch configuration settings from 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"
        }

Aucun commentaire:

Enregistrer un commentaire