pghalliday/grunt-mocha-test

Multiple reporters

fcaraujo opened this issue · 7 comments

Hi,
How about change options.reporter for an array?

Thanks

i don't think mocha supports multiple reporters. I have used the mocha-multi module to add this functionality in the past

https://www.npmjs.com/package/mocha-multi

In fact, I did a little research and it's came up before create this, but the ideia is we find a way to workaround while it's not supported. I read here that's a day we'll have it in production: http://www.juliengilli.com/2013/12/14/Using-multiple-reporters-with-Mocha/
What do you think?

tbh, I think the workaround is to use mocha-multi, I haven't tried it in a config of my own. But I think it will work if you add your task like this:

    // Configure a mochaTest task
    mochaTest: {
      test: {
        options: {
          reporter: 'mocha-multi',
          reporterOptions: {
            Progress:{ 
              stdout:"/tmp/mocha-multi.Progress.out",
              options: {
                verbose: true
              }
           },
           spec: {
              stdout:"-"
           }
        },
        src: ['test/**/*.js']
      }
    }

Derived from the programatic example on the mocha-multi README. It should work because the options block here will be passed directly to the mocha constructor

Great! I'll try it when possible and return a feedback soon.
Thanks!

I believe that was close, although I don't know all the workflow behind the scenes and didn't work exactly as expected, my config:

mochaTest: {
    test: {
        src: watchFiles.mochaTests
        , options: {
            require: 'server.js'
            //, reporter: 'spec' // doc
            //, captureFile: 'report/mocha.txt' // html
            , reporter: 'mocha-multi'
            , reporterOptions: {
                Progress:{
                    stdout: 'report/mocha.txt',
                    //stdout:"-",
                    options: {
                        verbose: true
                    }
                },
                spec: {
                    stdout:"-"
                }
            }
        }
    }
    , coverage: {
        options: {
            reporter: 'html-cov',
            quiet: true,
            captureFile: 'report/coverage/back/mocha_result.html'
        },
        src: [
            //'app/**/*.js'
            'app/tests/*.js'
            //'app/controllers/**/*.js'
            //, 'app/models/**/*.js'
            //, 'app/modules/**/*.js'
            //, 'app/routes/**/*.js'
        ]
    }
}

If I use reporter: 'mocha-multi' the task is not finished, I run my grunt but the console doesn't return (even failing a test or not).
With reporter: 'spec'it's ok.

Thanks

I just tested with this project

https://github.com/pghalliday/grunt-mocha-multi

Worked fine for me

Closing as not reproducible