简体   繁体   English

使用WebStorm中的任意NodeJS单元测试框架进行调试

[英]Debugging with arbitrary NodeJS unit testing frameworks in WebStorm

I have forked a NodeJS project that uses the Test Anything Protocol (node-tap). 我已经分叉了一个使用“测试任何协议”(node-tap)的NodeJS项目。 I am using the WebStorm 8.0.1 IDE. 我正在使用WebStorm 8.0.1 IDE。 I would now like to do step debugging when running the unit tests. 我现在想在运行单元测试时进行步骤调试。 Since tap seems pretty obscure in the world of Node, of course there's no run/debug configuration for that framework built into WebStorm. 由于Tap在Node的世界中似乎很晦涩,因此WebStorm中内置的该框架当然没有运行/调试配置。

I was able to run the tests through the IDE by configuring a Node.js run configuration with these settings: 通过使用以下设置配置Node.js运行配置,我能够通过IDE运行测试:

Node interpreter: C:\Program Files\nodejs\node.exe
Node parameters: --debug-brk
Working directory: {my project directory}
JavaScript file: node_modules\tap\bin\tap.js
Application parameters: test/test-*.js

However, when debugging with this configuration, my breakpoints are not hit. 但是,在使用此配置进行调试时,不会遇到断点。 Additionally, even inserting a debugger; 此外,甚至插入debugger; statement does not trigger a break. 语句不会触发中断。

Is there a way for me to specifically run tap tests in WebStorm? 我有办法在WebStorm中专门运行抽头测试吗? If not, why do you suppose the breakpoints in my tests are not being hit? 如果没有,为什么您认为我的测试中的断点没有被击中?

In digging through the tap module, it appears that all it does is launch each test file in a child process that runs node; 在挖掘tap模块中,似乎所做的只是在运行节点的子进程中启动每个测试文件。 it then just consumes its output which conforms to the Test Anywhere Protocol. 然后,它仅消耗其符合Test Anywhere协议的输出。

So for me to debug, I can just debug running my test JS directly with Node. 因此,对于我进行调试,我可以直接使用Node调试运行测试JS。 This seems to work fine. 这似乎很好。 Hopefully this will help anyone else unfamiliar with this test framework. 希望这可以帮助其他不熟悉此测试框架的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM