karma-runner / grunt-karma

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

Fatal error running multiple karma targets in one grunt task #153

Closed brinkkemper closed 9 years ago

brinkkemper commented 9 years ago

We're using Grunt to build multiple, but similar, applications in one build. Each app has files with the same names like HomeController, MenuController. So we split up the karma targets per application so dependencies are loaded only from the shared and specific application being tested. However, we do want all applications to be testes when deploying so we want to run all these targets on after another.

Fatal error
When using grunt to run the multiple karma targets it only runs the first successful and fails to run the second. Fatal error: listen EADDRINUSE The error is somehow related to a port being used.

Grunt-karma config

var dep = [
  'bower_components/**/*.js',
  'app/shared/**/*.js',
];

module.exports = {
  options: {
    configFile: 'test/karma.conf.js',
    reporters: ['brackets', 'html', 'junit', 'coverage'],
    browsers: ['PhantomJS'],
    port: 9002,
    singleRun: true
  },
  A: {
    options: {
      files: dep.concat([       
        'app/A/src/**/*.js'
      ]),      
    }
  },
  B: {
    options: {
      files: dep.concat([
        'app/B/src/**/*.js'
      ]),      
    }
  }
};

when running: grunt karma this ends with a Fatal error: listen EADDRINUSE I've also create a question on stack overflow. I hope someone can help me out!

dignifiedquire commented 9 years ago

I think this is the same bug as was tried to be solved in #57

brinkkemper commented 9 years ago

"tried to be solved"? Did it make it to a release? Can I help?

dignifiedquire commented 9 years ago

See my comment https://github.com/karma-runner/grunt-karma/pull/57#issuecomment-54463199 for what is left to do, as the author has been pretty silent, feel free to create a new PR based on that

brinkkemper commented 9 years ago

I believe @mokkabonna is right in stating his solution is not ideal and the karma-server should be stopped after completing a singleRun. Abusing the background option doesn't solve the problem.

Workaround I've managed to run the karma tasks separately by chaining grunt commands on the CML instead of inside a grunt task. that works for us.