简体   繁体   English

如何与mocha和node-inspector并行运行grunt任务

[英]How to run with mocha and node-inspector parallel with grunt tasks

At the moment I am running tests with simple-mocha grunt task. 目前,我正在使用简单上手的grunt任务进行测试。 I want to debug the code while running the tests. 我想在运行测试时调试代码。 How would I do that with grunt? 我该怎么做呢?

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

I can think of two ways of achieving this. 我可以想到两种方法来实现这一目标。 One is using this grunt task as a step of your own test-debug task (does exactly the same as your simplemocha task but runs grunt-debug first): https://github.com/burnnat/grunt-debug 一个正在使用此grunt任务作为您自己的test-debug任务的步骤(与您的simplemocha任务完全相同,但首先运行grunt-debug): https : //github.com/burnnat/grunt-debug

You must enable the plugin by adding this to your Gruntfile: 您必须通过将插件添加到您的Gruntfile中来启用该插件:

grunt.loadNpmTasks('grunt-debug');

and then prepend debug before running your existing task, in console: 然后在控制台中运行现有任务之前先进行debug

grunt debug simplemocha

Or, you could invoke nodejs --debug passing the main grunt script and arguments. 或者,您可以通过传递主要grunt脚本和参数来调用nodejs --debug A convenient way to do that in Linux bash would be nodejs --debug $(which grunt) simplemocha . 在Linux bash中执行此操作的便捷方法是nodejs --debug $(which grunt) simplemocha

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

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