使用 node-inspector 调试 jasmine-node 测试 [英] Debugging jasmine-node tests with node-inspector

查看:16
本文介绍了使用 node-inspector 调试 jasmine-node 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道这是否可能吗?节点检查器的大多数示例似乎都适合调试调用的网页.不过,我希望能够调试 jasmine-node 测试.

Does anyone have any idea if this is possible? Most of the sample for node-inspector seemed geared toward debugging an invoked webpage. I'd like to be able to debug jasmine-node tests though.

推荐答案

最后我写了一个叫做 toggle 的小工具:

I ended up writing a little util called toggle:

require('tty').setRawMode(true);
var stdin = process.openStdin();

exports.toggle = function(fireThis)
{
    if (process.argv.indexOf("debug")!=-1)
    {
        console.log("debug flag found, press any key to start or rerun. Press 'ctrl-c' to cancel out!");
        stdin.on('keypress', function (chunk, key) {
            if (key.name == 'c' && key.ctrl == true)
            {
                process.exit();
            }
            fireThis();
        });
    }
    else
    {
        console.log("Running, press any key to rerun or ctrl-c to exit.");
        fireThis();
        stdin.on('keypress', function (chunk, key) {
            if (key.name == 'c' && key.ctrl == true)
            {
                process.exit();
            }
            fireThis();
        });



    }
}

你可以把它放到你的单元测试中,比如:

You can drop it into your unit tests like:

var toggle = require('./toggle');

toggle.toggle(function(){

    var vows = require('vows'),
    assert = require('assert');

    vows.describe('Redis Mass Data Storage').addBatch({

....

然后运行您的测试,例如:node --debug myfile.js 调试.如果你运行调试切换将等到你除了 ctrl-c 之外的任何东西.Ctrl-c 退出.还可以重新运行,很好.

And then run your tests like: node --debug myfile.js debug. If you run debug toggle will wait until you anything but ctrl-c. Ctrl-c exits. You can also rerun, which is nice.

w0000t.

这篇关于使用 node-inspector 调试 jasmine-node 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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