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
1
vote
3 answers

Error: [$injector:unpr] Unknown provider: dataProvider <- data

This is my Js code (function () { angular.module('app',[]) .factory('code', function ($http, svc, $q) { function getCodeByID(id) { return $http.get(svc.get('my-application') + id) .then(function (res) { …
1
vote
2 answers

TypeError: undefined is not a constructor (evaluating 'angular.controller('myView')')

I'm getting the below error while doing karma/jasmine unit testing for both the test cases.I tried by modifying the controller by adding angular.controller in the spec file even then it is not working.Is there any way to fix? TypeError: undefined…
Hema Nandagopal
  • 668
  • 12
  • 35
1
vote
0 answers

How to unit test the angularjs injector, outside of a controller?

As part of an AngualrJS app, I have to retrieve user details from a REST api before bootstrapping the application. var initInjector = angular.injector(['ng']); var $http = initInjector.get('$http'); $http.get('../api/user').then( function…
Joseph McCarthy
  • 897
  • 2
  • 19
  • 41
1
vote
0 answers

Karma not running any unit test cases

I am trying to set up Karma for a small demo project. The problem is that Karma is not executing any test cases. My project has only two .js files: app/js/app.js and test/spec/app.spec.js My karma config file is as follows: module.exports =…
aryan87
  • 119
  • 1
  • 12
1
vote
1 answer

Setting up Karma for an angular library

I am currently building an Angular library, and I wanted to be able to run some tests. After following these instructions I managed to set up everything properly and actually be able to run my tests. Main question Although everything runs…
Thodoris
  • 712
  • 2
  • 8
  • 23
1
vote
0 answers

Karma - Jasmine fails with error "TypeError: null is not an object"

I am trying to test my very simple vanilla javascript code. I am using PhantomJS launcher. I suspect, that somehow it can't see the DOM elements, so there is null for the object that is assigned by DOM element. Do I need to include HTML in the…
brainmassage
  • 1,234
  • 7
  • 23
  • 42
1
vote
1 answer

Run karma test from JS without a config file

Is there any way I can run karma without specifying a static config file but giving it a configuration object instead? The ideal scenario would look something like: const karmaConfig = {...}; gulp.task('test', function (done) { new Server({ …
Marcelo Lazaroni
  • 9,819
  • 3
  • 35
  • 41
1
vote
1 answer

Why is Karma failing here without an error message - no test being run

I am running a fairly complicated front end stack. I am using node, gulp, webpack, and angular 1.5 with ES6. I set up my project using yo fountain generator. I wrote some tests (which failed) but noted that I was getting another unexpected fail - so…
Sam Redway
  • 7,605
  • 2
  • 27
  • 41
1
vote
2 answers

PhantomJS not Working on OS-X Sierra

I recently upgraded the OS from El Capitan to Sierra. Now I can not run the JS unit test suit and it gives the following error in the console. [exec] INFO [framework.browserify]: bundle built [exec] INFO [karma]: Karma v0.12.35 server started at…
1
vote
2 answers

gulp.watch causes "task completion callback called too many times"

When I change a file (like HelloWorld.js), I want to run a specific test suite (called HelloWorldSpec.js) using Karma. Therefore I created this Gulp task: gulp.task('dev', function(done) { // Watch source code changes …
Benny Code
  • 51,456
  • 28
  • 233
  • 198
1
vote
1 answer

gulp karma issue browser never start

I have node 4.4.3 npm 3.8.6 protractor: 3.2.2 installed globally gulp 3.9.1 installed globally and locally with a link package.json "devDependencies": { "connect": "3.4.1", "gulp-load-plugins": "1.2.0", "gulp-protractor":…
Eric Soucy
  • 183
  • 1
  • 1
  • 6
1
vote
0 answers

Error while running test case in Angular + karma

Getting below error on running test case Controller: LoginCtrl, test should have a empty loginUser object FAILED minErr/<@D:/XAMPP/htdocs/abc/lib/angular/angular.js:68:12 loadModules/<@D:/XAMPP/htdocs/abc/lib/angular/angular.js:4385:15 …
1
vote
2 answers

Uncaught Error: Module name "lib/chai" has not been loaded yet for context: use require([])

i m using karma-mocha ..my karma.conf file is working with karma-jasmine...but not working with karma-mocha....my karma.conf file:-- module.exports = function(config){ config.set({ basePath : '../app', preprocessors: { …
1
vote
0 answers

Unit-test Karma about Parse.com on AngularJS

I am very new about AngularJs, Parse and Karma.This time the problem I meet I didn't search the similar solution online. So I hope anyone good at these parts can help me. To make the Parse can run in my project, I install the angular-parse-patch…
Mengxi Wang
  • 81
  • 1
  • 8
1
vote
0 answers

Configure Karma to use global PhantomJS install on Linux Jenkins

I'm trying to get my Karma Unit tests to run on a remote Jenkins server. This Jenkins server is running on Linux with an old version of PhantomJS already installed and PHANTOMJS_BIN defined in the env. I'm using the gulp-karma and…
Cesar
  • 199
  • 13