eri*_*h z 5 cucumberjs visual-studio-code
我正在使用Visual Studio Code构建cucumberjs测试.我能够从命令行使用npm运行测试,并且我能够使用启动配置在VS Code中运行它们.
但是,我无法从Visual Studio代码中调试测试.这是在Windows 7上,VSCode 1.12.1
基本文件结构:
.
+-- .vscode
| +-- launch.json
+-- features
| +-- step_definitions
| | +-- sampleSteps.js
| +-- support
| | +-- customWorld.js
| +-- sampletest.feature
+-- node_modules
| +-- .bin
| | +-- cucumberjs
+-- package.json
+-- README.md
Run Code Online (Sandbox Code Playgroud)
在package.json里面,我有以下内容:
"scripts": {
"test": "./node_modules/.bin/cucumberjs"
},
Run Code Online (Sandbox Code Playgroud)
从命令行,我可以运行npm test或npm run-script test成功.我有一个launch.json配置如下:
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run-script",
"test"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我从VS Code中运行调试器时,它只运行测试,给我结果,但不尊重断点.
我希望能够逐步完成我的代码,似乎launch.json就是这样做的工具.我试过直接从launch.json调用黄瓜,但在这种情况下它似乎没有找到所有正确的文件(包括cucumberjs).
我能够让它与这个 launch.json 一起工作:
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Via NPM",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"env":{
"NODE_PATH": "test/"
},
"runtimeArgs": [
"run-script",
"debug"
],
"port": 5858
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后在package.json中:
"scripts": {
"debug": "node --debug-brk=5858 ./node_modules/cucumber/bin/cucumber.js --profile TEST -t '@my_tag'"
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!(请注意这是在 MacOS 上完成的)
| 归档时间: |
|
| 查看次数: |
2335 次 |
| 最近记录: |