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
30
votes
1 answer

What does npm mean by 'Skipping failed optional dependency'?

Latest version of node and npm causing problems in running karma. When I try to install karma-cli npm i -g karma karma-cli I get following warning: npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not…
Mithun Shreevatsa
  • 2,689
  • 7
  • 34
  • 71
14
votes
1 answer

Karma Code Coverage - Always 100%?

Good Morning, I am having a weird issue that I cannot seem to solve. I have my Karma tests written out and the execute correctly, but when I try to wire up the code coverage for Karma it just spits out 100% no matter what. I looked at the other…
Primm
  • 618
  • 2
  • 8
  • 16
10
votes
1 answer

Set debugging option in Gulp Karma test

According to this post (and the general internet) if I want to run a Karma test without these kinds of code coverage commands... __cov_9C0014nbzu2SxN3FICah6Q.f['35']++; __cov_9C0014nbzu2SxN3FICah6Q.s['138']++; ...I simply need to set the --debug…
NealR
  • 8,689
  • 51
  • 142
  • 274
9
votes
2 answers

gulp task can't find karma.conf.js

I am trying to run karma test via a gulp task. I use https://github.com/karma-runner/gulp-karma and for some reason gulp cannot locate my karma.conf.js. That file is located in the same folder as the gulpfile. The root of the project. No matter what…
Hcabnettek
  • 11,896
  • 36
  • 120
  • 185
9
votes
2 answers

Karma exits with code 1 when it doesnt execute any spec tests

Karma test runs fine but exits with code 1 if 0 of 0 tests are run. Does anyone know how to return exit code 0 and normally exit in this case? Using gulp-karma which fails the task when no specs are run.
Encore PTL
  • 7,144
  • 8
  • 35
  • 72
7
votes
3 answers

Asp.Net 5 and Aurelia Karma tests

I'm trying to setup the skeleton-navigation project for Aurelia in a new ASP.NET 5 application. I've tried numerous things and believe I'm getting close, but am really getting caught up on the client-side tests. I downloaded the skeleton project…
peinearydevelopment
  • 8,782
  • 5
  • 36
  • 65
7
votes
1 answer

Karma config file - use of basePath

I am just trying out some things in my Karma config file, and have a files array set like so: files: [ '../dist/app/**/*.mock.js', '../dist/assets/scripts/bower_libs.js', '../dist/assets/scripts/main.js', '../test/src/**/*.js', …
mindparse
  • 7,083
  • 17
  • 64
  • 146
6
votes
1 answer

How do i go to parent directory when using __dirname?

Directory structure : WebApiRole GulpFile.js test Karma.conf.js Gulp code from GulpFile.js gulp.task('test', function (done) { karma.start({ configFile: _configFile: __dirname + '\\..\\test\\karma.conf.js', singleRun: true …
Malik
  • 2,430
  • 5
  • 27
  • 41
6
votes
2 answers

karma-ng-html2js-preprocessor not working gulp + angular + karma + ng-html2js

I can't make karma-ng-html2js-preprocessor working for external template. Package Json file: ..... "gulp-karma": "*", "karma-coverage": "*", "karma-jasmine": "*", "karma-ng-html2js-preprocessor": "*", …
rak
  • 61
  • 1
  • 4
5
votes
0 answers

Error in using Karma with SystemJS, gulp, and TypeScript

I am new to node.js stack like npm, gulp etc. I had wrote some JavaScript unit test cases earlier, and now want to use Karma as test runner. However, after a few attempts I am completely lost now. To start, I have following project…
Sayan Pal
  • 4,226
  • 4
  • 42
  • 72
5
votes
1 answer

Gulp server issue while trying to run

I seem to get an odd error when trying to get a project run, its seems to work fine in mac, but i am not able to get it run in Windows/ubuntu /home/nicholas/Desktop/Workspace/projectx/node_modules/gulp/node_modules/orchestrator/index.js:47 …
Nicholas Francis
  • 3,233
  • 2
  • 16
  • 20
4
votes
1 answer

Phantomjs launcher Fatal Windows Exception encountered

I am having issues running karma tests through gulp. I am using the phantomjs launcher plugin, and when it attempts to launch I see the following: [09:27:02] Starting 'karma-tests'... DEPRECATED: use your own version of lodash, this will go away in…
mindparse
  • 7,083
  • 17
  • 64
  • 146
4
votes
3 answers

Angular2 Jasmine Test Image Source

I have a component with an image in template When running karma task it throws such error Uncaught Error: Cannot find module "../images/logo.png" To mention that app renders the image fine ,…
rjomir
  • 252
  • 3
  • 11
4
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
  • 538
  • 8
  • 21
4
votes
1 answer

How to debug Javascript test files in the browser using gulp test and karma

I wrote a javascript test using the jasmine framework, and I run my tests using with "gulp test". Below is my test.js gulp.task('test', function(done) { new Karma({ configFile: __dirname + '/../../karma.conf.js', singleRun: false },…
Vibol
  • 436
  • 6
  • 20
1
2 3 4 5