Questions tagged [gulp-karma]

Karma integration into Gulp.js-based build.

gulp-karma is a gulp plugin that can start Karma test runner.

Example of usage:

var gulp = require('gulp');
var karma = require('gulp-karma');

var testFiles = [
  'client/todo.js',
  'client/todo.util.js',
  'client/todo.App.js',
  'test/client/*.js'
];

gulp.task('test', function() {

  // Be sure to return the stream 
  return gulp.src(testFiles)
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: 'run'
    }))
    .on('error', function(err) {

      // Make sure failed tests cause gulp to exit non-zero 
      throw err;
    });
});

gulp.task('default', function() {
  gulp.src(testFiles)
    .pipe(karma({
      configFile: 'karma.conf.js',
      action: 'watch'
    }));
});
74 questions
4
votes
1 answer

Gulp karma "spawn ENAMETOOLONG" when processing many files

We're using gulp-karma plugin to gulp for our testing and PhantomJS. We're running on Windows and PhantomJS is a .exe file. Our files that has the tests has grown and now we're getting the error "spawn ENAMETOOLONG". From what I've gather from this…
Arne H. Bitubekk
  • 2,963
  • 1
  • 27
  • 34
3
votes
1 answer

How to set env variable PHANTOMJS_BIN

Ok I see this question has been asked before however when I looked at the answers I am still unable to correctly set the environment variable. I tried using the export command but export is not recognized as an internal or external command. Does…
Flash
  • 924
  • 3
  • 22
  • 44
3
votes
1 answer

Build ES6 application using Gulp + Karma + PhantomJS

I would like to build my Javascript ES6 application using Gulp, Karma and PhantomJS but Phantom doesn't want to hear about any ES6 expression. I'm using PhantomJS v2.1 which is supposed to support ES6. I've also tried without browserify and babelify…
Tdy
  • 863
  • 12
  • 28
3
votes
1 answer

Unknown provider error in jasmine test

I am a newbie to angularjs. I am running into an issue with this jasmine test I am trying to write. I get this error - "Error: [$injector:unpr] Unknown provider: $routeProvider". The actual app works fine, I get this error only in tests. [09:13:05]…
sp4sp7
  • 58
  • 1
  • 7
3
votes
0 answers

Test individual modules with Karma

There are few independant modules in my web app, and I want to test them individually. Is is possible to do with Karma? Details There are parts of gulpfile.js and karma.conf.js: //gulpfile.js gulp.task('test', function (done) { new karmaServer({ …
Alex Povar
  • 4,890
  • 3
  • 29
  • 44
3
votes
2 answers

How to run second task only when karma test task is successful with Gulp?

I am using Gulp. I have a deploy task that runs after test task. The problem is that deploy task runs even if test failed. Is there a way to run deploy task only when tests are successful in gulp? gulp.task('test', function() { return…
Evgenii
  • 36,389
  • 27
  • 134
  • 170
2
votes
1 answer

nwjs and karma-mocha not playing nice

I am having issues testing my NW.js app using Karma. Tests that used to work now don't after updating ??? (I'm not sure which update killed me) START: 13 07 2016 08:33:30.517:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/ 13 07…
ed4becky
  • 1,488
  • 1
  • 17
  • 54
2
votes
0 answers

Gulp + Karma: Karma won't stop

I am running Karma with Gulp, something like this: gulp.start(`karma`); And then: module.exports = (gulp, plugins) => gulp.task('karma', done => { plugins.util.log('Testing with Karma'); const server = new Server({ configFile:…
Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96
2
votes
1 answer

Karma test throws a Provider not found error on a service

I am trying to create a simple service and test it in jasmine-karma environment. I have used Angular 1.5.5 For some reason I keep getting a error Chrome 46.0.2490 (Windows 7 0.0.0) reddit api service should do something FAILED Error:…
manu
  • 77
  • 1
  • 3
  • 14
2
votes
2 answers

Manually trigger Karma to rerun tests

I know that Karma has a built-in autoWatch option that will cause my tests to be rerun when a test file changes: var server = new karmaServer({ autoWatch: true, autoWatchBatchDelay: 250, }); server.start(); Is there a way to trigger this…
Nathan Friend
  • 12,155
  • 10
  • 75
  • 125
2
votes
2 answers

karma config with browserify/babel

I have a karma conf that I try to make work with babel/browserify. It looks like this: module.exports = function(config) { config.set({ browsers: ['Chrome'], frameworks: ['jasmine'], plugins: [ 'karma-jasmine', …
viktor
  • 1,050
  • 1
  • 12
  • 26
2
votes
0 answers

Gulp exit in error with Karma tests failing

Fairly new to testing AngularJS applications, I am using a mixture of Gulp (4.0), AngularJS (1.4.5), Karma (0.13.15) and Jasmine (2.3.4) for this project. I'm using OS X (10.11.1). Upon success, the tests run and Gulp exits smoothly $ gulp…
Mathieu Marques
  • 1,678
  • 15
  • 33
2
votes
1 answer

karma + gulp + jasmine + commonjs/browserify

I'm trying to get my karma jasmine unit testing back up running after introducing a bunch of commonJS (at least I guess that's what it's called) and starting to use package.json and upgrading all packages and get errors everywhere. Running gulp…
Giszmo
  • 1,944
  • 2
  • 20
  • 47
2
votes
1 answer

Gulp Karma "Script error"

I'm using gulp-karma + mocha + chai + sinon in order to unit test some front end. The nasty thing I keep getting into is the "Script Error" message that karma spits out without any other relevant detail. How can I make karma display the source of…
Dan Ochiana
  • 3,340
  • 1
  • 30
  • 28
1
vote
0 answers

How to exclude customHeaders for selected components in karma?

customHeaders: [{ match: 'context.html', => customContextFile name: 'Content-Security-Policy', value: 'default-src 'none'; connect-src 'self';' }] This customHeaders is getting added to all the components while testing and I want to exclude…
RS17
  • 773
  • 1
  • 9
  • 23