如何debugging与Visual Studio的JavaScript在摩卡testing?
如果使用节点很容易debugging它:
//.vscode/launch.json "configurations": [ { "name": "Launch", "type": "node", "request": "launch", ...
但是,如果我正在使用摩卡testing。 我怎样才能debugging呢?
我试图把:
"configurations": [ { "name": "Launch", "type": "mocha", "request": "launch",
但是这是无效的。 任何人有任何想法?
先谢谢了。
-
在.vscode / launch.json中创build这个新的debugging目标
{ "name": "Unit tests", "type": "node", "program": "${workspaceRoot}/mocha.js", "stopOnEntry": true, "args": ["${workspaceRoot}/TESTTODEBUG.js"], "runtimeExecutable": null, "env": { "NODE_ENV": "test" }
-
创build文件mocha.js
'use strict'; // Dependencies var Mocha = require('mocha'); // Determine which tests to run based on argument passed to runner var args = process.argv.splice(2); //var args = ["./tests/unit/services/supra-statement.service.test.js"]; var files; //Define Mocha var mocha = new Mocha({ timeout: 60000, reporter: 'spec', globals: ['Associations', 'CREATE_TEST_WATERLINE', 'DELETE_TEST_WATERLINE'] }); args.forEach(mocha.addFile.bind(mocha)); //Run unit tests mocha.run(function (failures) { process.exit(failures); });
-
使用unit testing选项运行debugging器