【问题标题】:How to run with mocha and node-inspector parallel with grunt tasks如何使用 mocha 和 node-inspector 与 grunt 任务并行运行
【发布时间】:2014-10-03 10:56:47
【问题描述】:

目前我正在使用 simple-mocha grunt 任务运行测试。我想在运行测试时调试代码。我将如何使用 grunt 来做到这一点?

    simplemocha: {
        options: {
            globals: ['expect'],
            timeout: 3000,
            ignoreLeaks: false,
            ui: 'bdd',
            reporter: 'tap'
        },
        all: {
            src: ['test/*.js']
        }
    },

【问题讨论】:

    标签: node.js gruntjs mocha.js node-inspector


    【解决方案1】:

    我可以想到两种方法来实现这一点。一个是将此 grunt 任务用作您自己的测试调试任务的一个步骤(与您的 simplemocha 任务完全相同,但首先运行 grunt-debug):https://github.com/burnnat/grunt-debug

    您必须通过将其添加到您的 Gruntfile 来启用该插件:

    grunt.loadNpmTasks('grunt-debug');
    

    然后在控制台中运行现有任务之前添加debug

    grunt debug simplemocha
    

    或者,您可以调用 nodejs --debug 并传递主要的 grunt 脚本和参数。在 Linux bash 中执行此操作的一种便捷方法是 nodejs --debug $(which grunt) simplemocha

    【讨论】:

    • 我将如何使用 grunt-debug 来做到这一点。你能给出代码示例吗?
    • 对不起@PrashanFernando,我粘贴了错误的链接。我添加了正确的代码和一个小代码 sn-p,这正是他们建议的做法。此外,您可以定义一个任务别名来直接调用它(参见gruntjs.com/creating-tasks#multi-tasks)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 2015-08-04
    • 1970-01-01
    • 2014-02-17
    • 2014-11-17
    • 1970-01-01
    • 2015-07-10
    相关资源
    最近更新 更多