调查摩卡测试的阻力最小的是什么? [英] what's the least resistance path to debugging mocha tests?

查看:208
本文介绍了调查摩卡测试的阻力最小的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑2016年11月:节点现在有一个内置的调试器,您可以从开始 - 检查。这个答案解释了: http://stackoverflow.com/a/39901169/30946

Edit Nov 2016: Node now has a built in debugger that you can start with --inspect. This answer explains it: http://stackoverflow.com/a/39901169/30946.

我正在咖啡书中建立摩卡考试。在测试的顶部,我有:

I'm building a mocha test in coffeescript. Right at the top of the test I have:

require "../assets/js/theObject.coffee"
debugger
ss = new TheObject()

我想停止在该调试器因为 theObject.coffee 中的对象未被加载。我正在使用节点检查器,它可以工作,排序。

I'd like to stop on that debugger line because the object in theObject.coffee isn't being loaded. I'm using node-inspector and it works, sorta.

我的过程是:


  1. start node-inspector

  2. 在命令行运行测试,使用 mocha - compilers coffee:coffee-script ./test/theObjectTests.coffee --ui bdd -d --debug-brk

  3. 转到节点检查器页面,如果已经打开,请刷新它

  4. 等待文件 theObject.coffee 加载,然后在正确的行上放置一个断点

  1. start node-inspector
  2. run the test at the command line with mocha --compilers coffee:coffee-script ./test/theObjectTests.coffee --ui bdd -d --debug-brk
  3. go to the node-inspector page, refresh it if it is already open
  4. wait for the file theObject.coffee to be loaded, then put a breakpoint on the correct line

必须是一个更简单的方法。看起来我应该能够调试器运行,只是停止在调试器行,但我无法找到。我有一个WebStorm,它有一个调试器(

There must be an easier way. It seems like I should be able to have a debugger running and just have it stop on that debugger line, but I'm not able to find that.

-and-mocha.htmlrel =nofollow noreferrer>本文讨论设置它运行摩卡测试,但它没有帮助我),但是当我启动它,它失败。在WebStorm调试窗口中运行的命令是:

I have WebStorm, which has a debugger (this article discusses setting it up to run mocha tests, but it didn't help me), but when I start it, it fails. The command that's running in the WebStorm debug window is:

"C:\Program Files\nodejs\node.exe" --debug-brk=64232 C:\Users\jcollum\AppData\Roaming\npm\_mocha

C:\Users\jcollum\AppData\Roaming\npm\_mocha:2
basedir=`dirname "$0"`

I怀疑可能是Windows的具体问题。

I suspect that might be a windows specific issue.

Env:Windows 7,Webstorm,node 0.8.16,mocha 1.7.4,git-bash

Env: Windows 7, Webstorm, node 0.8.16, mocha 1.7.4, git-bash

问题是:如果从Mocha开始,最简单的方法是让调试器轻松停在调试器上?简单就是这里的关键词。

The question: if you're starting from scratch with Mocha, what's the easiest way to get a debugger going that will stop on a debugger line easily? Easy is the keyword here.

编辑:自从问这个我已经停止使用Windows并且正在Ubuntu工作。我的摩卡调试过程(我很少使用)是一样的。

since asking this I've stopped using Windows and am working in Ubuntu. My mocha debugging process (which I use infrequently) is the same.

推荐答案

编辑,多年以后:Node 6+中最短的路径是: mocha --debug-brk --inspect ./test.js 加上Node Inspector Manager插件。

Edit, years later: the shortest path in Node 6+ is: mocha --debug-brk --inspect ./test.js coupled with the Node Inspector Manager plugin.

许多周后,没有答案。这是我找到的最快的路径。

Many weeks later, no answers. Here's the quickest path that I found.


  1. 写mocha测试

  2. 安装 node-inspector

  3. 开始节点检查器 - 现在将在5858上收听

  4. 开始使用的mocha测试 - debug-brk

  5. 此时摩卡考试在第一行暂停

  6. 打开网页浏览器并转到本地主机:5858

  7. (可选:在测试文件的顶部添加一个调试器行,停止后设置断点该文件)

  8. 点击F10以获取代码

  9. 节点检查器将停止在任何具有调试器的行偶尔,它不会将代码文件的窗口移动到正确的位置,所以你必须点击F10才能进入下一行并显示文件的位置。

  1. write mocha tests
  2. install node-inspector
  3. start node-inspector -- it will now be listening on 5858
  4. start the mocha test with --debug-brk
  5. at this point the mocha test is paused on the first line
  6. open a web browser and go to localhost:5858
  7. (optional: add a debugger line at the top of your test file, set breakpoints after it stops in that file)
  8. hit F10 to get the code to go
  9. node-inspector will stop on any line that has debugger on it. Occasionally it won't move the code file's window to the right place, so you'll have to hit F10 to get it to step to the next line and show where it's at in the file.

命令行:

节点检查器和mocha - 编译器咖啡:咖啡脚本/注册./test/appTests.coffee --ui bdd -d -g应该X然后Y--debug-brk

这篇关于调查摩卡测试的阻力最小的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆