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
  • 3,588
  • 9
  • 50
  • 95
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
  • 1,438
  • 3
  • 12
  • 16
13
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
  • 8,084
  • 10
  • 43
  • 78
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
  • 10,189
  • 61
  • 159
  • 299
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
  • 12,678
  • 38
  • 124
  • 190
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
  • 11,042
  • 5
  • 48
  • 76
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
  • 6,115
  • 27
  • 90
  • 191
6
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
  • 304
  • 3
  • 12
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
  • 3,520
  • 7
  • 29
  • 42
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,768
  • 5
  • 43
  • 82
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,623
  • 2
  • 19
  • 22
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
  • 6,115
  • 27
  • 90
  • 191
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
  • 615
  • 1
  • 8
  • 25
4
votes
1 answer

Karma closing browsers after gulp test

I'm running basic jasmine tests using the Chrome and Firefox launchers in karma, from gulp. But my browsers are always being closed afterwards. Regardless of success or failure in tests, even after specifying single run as false in the task and the…
ChrisFletcher
  • 1,010
  • 2
  • 14
  • 31
1
2 3 4 5