如果我在控制台中运行,则测试运行正常
mocha --require ts-node/register tests/**/*.spec.ts
Run Code Online (Sandbox Code Playgroud)
注意:我安装了mocha和mocha -g
我想从Visual Studio Code运行单元测试
launcgh.js文件
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--require",
"ts-node/register",
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/tests/**/*.spec.ts"
],
"internalConsoleOptions": "openOnSessionStart"
},
Run Code Online (Sandbox Code Playgroud)
非常简单的测试文件
import { expect } from 'chai';
const hello = () => 'Hello world!';
describe('Hello function', () => {
it('should return hello world', () => {
const result = hello();
expect(result).to.equal('Hello world!');
});
});
Run Code Online (Sandbox Code Playgroud)
但在Visual Studio Code调试控制台中
/usr/local/bin/node --inspect-brk=15767 node_modules/mocha/bin/_mocha --require …
Run Code Online (Sandbox Code Playgroud) 测试新的Microsoft Visual Code Studio.试图设置一些环境变量,似乎设置它们使OpenDebug无法运行.引发错误"OpenDebug进程意外终止"
当环境变量被注释掉时,它运行时没有问题.
我使用它错了还是错误?