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
0 answers

Is it possible to serve JSON files with Karma?

I'm writing unit tests with karma. In my angular code I have this string: $http.get('data/config.json'); JSON files are places in src/data folder. When I am running tests the script can't load this data. Btw, I tried this in my karma.conf: files:…
Alex
  • 51
  • 1
  • 5
1
vote
0 answers

KarmaJS not working with node >= 0.12.x

I have recently upgrade to the latest version of node and have run into an issue getting Karma to work. I am using Gulp and this is an Angular application. In order to get as far I have, I had to reference the v1.0.0-0 tag of karma runner from…
thescientist
  • 2,906
  • 1
  • 20
  • 15
1
vote
1 answer

Access to projectDir from karma test?

Within a karma test beforeEach) block I would like to access (read) a file from the project directory. However, I do not know how to get access to that directory, since process.cwd() returns the directory the test is running in, which is a random…
ed4becky
  • 1,488
  • 1
  • 17
  • 54
1
vote
1 answer

Gulp task not accessing karma.conf.js file

I am using following gulp task to execute the karma/jasmine unit test cases . however i was not able access the karma.conf.js file for some reason. this problem occurs when i use this pathpackage to access the karma.conf.js file. gulp…
Malik
  • 3,520
  • 7
  • 29
  • 42
1
vote
0 answers

how to inject module dependencies in angular test unit with karma

it's the first time that i use angular application using generator and units tests with karma. i wanna create some angularjs unit test for my app based on bower, gulp, karma... this is my controller : (function() { 'use strict'; …
SLA
  • 11
  • 7
1
vote
1 answer

Gulp run karma tests - can't find variable: angular

When running gulp, the tests run just fine. On file change, the errors get thrown but then run and pass the tests. If I pull up the browser with tests running, it just errors out. I noticed the files aren't getting served as I specify. My current…
Tyler Pflueger
  • 827
  • 2
  • 12
  • 17
1
vote
3 answers

ES6 - how to test Jasime tests thru karma using ES6 like 'import' statement

I am new to javascript, trying to write a spec having an ES6 like import statement and then execute it thru Karma with pre-processors as traceur and browserify (to bundle and provide 'require' method). It continues to give me an error of invalid…
user4606322
  • 71
  • 2
  • 6
0
votes
1 answer

Running Gulp with Karma in Angular 6

I'm trying to execute a gulp task to run Karma after upgrading to Angular 6. Following the example in the readme on gulp-karma, var gulp = require('gulp'); var Server = require('karma').Server; /** * Run test once and exit */ gulp.task('test',…
nanoTitan
  • 562
  • 4
  • 7
0
votes
0 answers

Angular4 Karma-Jasmine test not running

I am trying to get my Karma-Jasmine tests set-up and can't work-out where I am going wrong. Can't seem to understand where the problem is and have tried various solutions from online searches have tried to change the 'target' and 'module' amongst…
Ram
  • 527
  • 1
  • 10
  • 26
0
votes
1 answer

TypeError: Cannot read property 'length' of undefined AngularJS Karma

I am a little stuck in the unit test, for the function hasAddress() but it seems that it doesn't work, and I think I don't have an idea how to do the angularjs unit test with Karma but I don't understand how to solve this part and I'm not sure what…
AnubisVolga
  • 311
  • 3
  • 18
0
votes
1 answer

TypeError: Cannot read property 'firstName' of undefined Unit Test AngularJS

I am stuck to do the Unit Test with Karma, I don't have idea how to the unit test because it's my first time. I am using AngularJS and the unit test is Karma. The thing is this: I'm using a service to obtain the firstName, lastName and PhoneNumber…
0
votes
1 answer

Cannot call beforeEach 'inject' on angularJS (FUSE Admin) unit testing using karma

I used FUSE Admin app on my project - http://fuse-angular-material.withinpixels.com/apps/dashboards/project. I already checked other samples and even run this code on a different project and works just fine. IT's just that I cannot inject the…
0
votes
1 answer

Karma/Jasmine how to call a method on an angularjs Factory

I need some help getting this test to run. I've spent way to much time on it. So i am stuck and need some help? I simply have a factory method, that has one method and i keep getting [Unable to get property 'method1' of undefined or null reference…
muscleman71
  • 91
  • 2
  • 13
0
votes
0 answers

DISCONNECTED - during karma unit test execution after ~2000 using gulp, can anyone know to resolve this issue?

Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2009 of 2294 (45 FAILED) DISCONNECTED (7 mins 21.244 secs / 6 mins 16.904 secs) Karma version: 0.13.22 gulp --version:- [12:18:06] CLI version 3.9.1 [12:18:06] Local version 3.9.1
0
votes
0 answers

How to automate test case generation (complete & running test case not just boilerplate) of an angular app?

I am a lazy programmer. I want to automate test case generation of my large angularjs app. Currently, I am using jasmine and karma. What I want is, to extract the module, components and methods dynamically and create a test case which should pass.…
JVM
  • 946
  • 1
  • 10
  • 23