microsoft / vscode-recipes

MIT License
5.87k stars 578 forks source link

Mocha: `opts` and node options such as `require` #206

Closed mhofman closed 3 years ago

mhofman commented 5 years ago

Since the launch.json uses the _mocha launcher, the node options present in any opts file will not be passed to the node process which is invoked directly by VSCode.

At the very least this should be documented. But I'd love to find a solution to avoid replicating my opts content in launch.json

support/mocha.opts:

-- require esm

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Mocha Test All with Options",
            "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
            "args": [
                "--opts", 
                "${workspaceFolder}/support/mocha.opts",
                "${workspaceFolder}/test"
            ],
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }
    ]
}
connor4312 commented 3 years ago

mocha.opts has been replaced with .mocharc, which seems to be loaded by _mocha without issues.