简体   繁体   中英

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

At the moment I am running tests with simple-mocha grunt task. 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

You must enable the plugin by adding this to your Gruntfile:

grunt.loadNpmTasks('grunt-debug');

and then prepend debug before running your existing task, in console:

grunt debug simplemocha

Or, you could invoke nodejs --debug passing the main grunt script and arguments. A convenient way to do that in Linux bash would be nodejs --debug $(which grunt) simplemocha .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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