karma-runner / grunt-karma

Grunt plugin for Karma.
MIT License
468 stars 116 forks source link

Events are fired twice when using background: true #143

Open 4kochi opened 9 years ago

4kochi commented 9 years ago

I developed a reporter for karma (https://github.com/litixsoft/karma-mocha-reporter) and have the issue that when the option background is true, the output of my reporter is not colored in the console.

I looked at you code and see that you do not set the stdio option for the node child process. This means the default is used (pipe). I set the option to stdio: 'inherit'and now the output of my reporter is colored. But now i have the effect that the onSpecComplete or onRunComplete events are fired twice and i have duplicate output. Do you have any idea why this is happening.

Here the code i changed:

var backgroundArgs = {
        cmd: 'node',
          args: process.execArgv.concat([
              path.join(__dirname, '..', 'lib', 'background.js'),
              JSON.stringify(data)
          ]),
          opts: {
              stdio: 'inherit'
          }
      };

Btw, the progress reporter which is bundled in karma has a colored output even without the stdio option set.

Thanks.