Questions tagged [karma-runner]

Karma provides developers a testing environment where they don't have to set up many things, rather just write code and get instant feedback in order to improve productivity and creativity.

karma-runner
Filter by
Sorted by
Tagged with
105 votes
4 answers
38k views

Can Protractor and Karma be used together?

If Protractor is replacing Angular Scenario Runner for E2E testing, does that mean I will still be able to use it with Karma as my E2E testing framework ?
holographic-principle's user avatar
891 votes
22 answers
1.0m views

npm check and update package if needed

We need to integrate Karma test runner into TeamCity and for that I'd like to give sys-engineers small script (powershell or whatever) that would: pick up desired version number from some config file ...
iLemming's user avatar
  • 35.3k
105 votes
9 answers
83k views

Karma run single test

I use karma to run tests. I have many tests and running all tests is a very slow process. I want to run only a single test in order to spend less time, because all tests are run about 10 minutes. Is ...
user avatar
76 votes
11 answers
135k views

Angular 1.6.0: "Possibly unhandled rejection" error [duplicate]

We have a pattern for resolving promises in our Angular app that has served us well up until Angular 1.6.0: resource.get().$promise .then(function (response) { // do something ...
Groucho's user avatar
  • 1,065
85 votes
8 answers
74k views

Loading a mock JSON file within Karma+AngularJS test

I have an AngularJS app set up with tests using Karma+Jasmine. I have a function I want to test that takes a large JSON object, converts it to a format that's more consumable by the rest of the app, ...
Aaronius's user avatar
  • 4,945
50 votes
7 answers
62k views

jasmine tests in karma: Uncaught ReferenceError: require is not defined

Karma can not recognize 'require' statement in JSFileSpec.js file. Running karma.conf.js: (function() { describe("DummyEmitter creation", function(){ return it("creation", function(){ ...
Igor Seliverstov's user avatar
44 votes
5 answers
21k views

UI-router interfers with $httpbackend unit test, angular js

This is a controller with a submit function: $scope.submit = function(){ $http.post('/api/project', $scope.project) .success(function(data, status){ $modalInstance.dismiss(true); ...
Joe's user avatar
  • 4,424
101 votes
29 answers
64k views

Error: You need to include some adapter that implements __karma__.start method

I'm trying to add some unit tests to one of my projects. So far I've installed and configured karma, and have installed jasmine. I've one test file in my test/ folder. The karma server has started, ...
Drew Noakes's user avatar
91 votes
8 answers
55k views

how to fix 404 warnings for images during karma unit testing

I'm unit testing one of my directives (angularjs) using grunt/karma/phantomjs/jasmine. My tests run fine describe('bar foo', function () { beforeEach(inject(function ($rootScope, $compile) { ...
Jeanluca Scaljeri's user avatar
71 votes
3 answers
86k views

Mocking AngularJS module dependencies in Jasmine unit tests

I'm attempting to unit test controller code inside a module that takes other modules as dependencies, but haven't been able to figure out how to mock them properly. I'm using the Jasmine Framework ...
fscof's user avatar
  • 1,593
52 votes
2 answers
42k views

angular cli exclude files/directory for `ng test --code-coverage`

I am running the following command to unit test and generate code code coverage report. ng test --code-coverage It is working fine and writing code coverage report in coverage folder. In this I got ...
Partha Sarathi Ghosh's user avatar
10 votes
2 answers
13k views

Getting "Mismatched anonymous define() module..." when I try running tests

I am trying to configure my karma jasmine unit testing with requirejs. But each time i run it, i am getting the below error: Chrome 34.0.1847 (Mac OS X 10.9.2) ERROR Uncaught Error: Mismatched ...
Priyabrat Nanda's user avatar
194 votes
10 answers
73k views

NPM cannot install dependencies - Attempt to unlock something which hasn't been locked

I've been trying to run an npm install on my package.json file, but I'm having a lot of trouble. It keeps saying "Error: Attempt to unlock XXX, which hasn't been locked" on all my dependences. Here'...
TJ Kirchner's user avatar
  • 4,321
109 votes
4 answers
131k views

Karma: Running a single test file from command line

So, I've been looking all over for this, found "similar" answers here, but not exactly what I want. Right now if I want to test a single file with karma, I need to do fit(), fdescribe() on the file ...
Gonçalo Vieira's user avatar
87 votes
2 answers
42k views

How to test nodejs backend code with Karma (testacular)

How do I setup Karma to run my backend unit tests (written with Mocha)? If I add my backend test script to the files = [], it fails stating that require is undefined.
Sylvain's user avatar
  • 19.2k
39 votes
4 answers
15k views

Karma throws error: Can not load "ng-html2js", it is not registered

I'm getting an error when I run karma start: $ karma start INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome WARN [preprocess]: Can not ...
Ph0en1x's user avatar
  • 10k
251 votes
15 answers
209k views

Running a single test file

Is there a way to run ng test for a single file instead of for the entire test suite? Ideally, I'd like to get the quickest possible feedback loop when I'm editing a file, but karma executes the ...
Elliot Larson's user avatar
81 votes
2 answers
61k views

Unit testing AngularJS factories that have dependencies

When unit testing an Angular factory (with Karma + Jasmine), how do I inject a stub dependency into the factory under test? Here's my factory: mod = angular.module('myFactoryMod', []); mod.factory('...
Roy Truelove's user avatar
  • 22.2k
56 votes
14 answers
70k views

Karma/Jasmine times out without running tests

I'm trying to run Karma/Jasmine from Grunt on a project generated with http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/ Karma launches PhantomJS (or Chrome) and, depending on ...
edoloughlin's user avatar
  • 5,831
42 votes
3 answers
27k views

Angular error running Karma tests: HTML5 mode requires a <base> tag

I have a single-page Angular app with a Rails backend. I am using a tag in my index.html file, but when I run my front-end unit tests using Karma, I get this: $location in HTML5 mode requires a <...
acobster's user avatar
  • 1,647
32 votes
1 answer
27k views

How to resolve $q.all promises in Jasmine unit tests?

My controller has code like below: $q.all([qService.getData($scope.id), dService.getData(), qTService.get()]) .then(function (allData) { $scope.data1 = allData[0]; $scope.data2 = allData[1]; $...
Rahul R.'s user avatar
  • 6,181
2 votes
1 answer
1k views

Jasmine, Karma, Angular how to write test on my Angular app?

I have just jumped to another project and, basically, I have been asked to write Unit tests. Since I have already know Protractor for e2e testing, I now switched to Karma and Jasmine to carry out unit ...
Mar3's user avatar
  • 69
2 votes
1 answer
4k views

Detecting Environment When Running Karma

I have two environments I'm running my tests in (locally, and travic ci). And I need to make a few tweaks in my tests if I'm running them locally. Is it possible to do it using Karma without having ...
Victor Savkin's user avatar
142 votes
8 answers
88k views

"TS2322: Type 'Timeout' is not assignable to type 'number'" when running unit tests

I have two TypeScript packages, and one package (Package A) depends on the other (Package B). Each package has a unit test set up using Karma. When I run unit tests for each individually after ...
dawsonc623's user avatar
  • 2,045
110 votes
8 answers
58k views

Running karma after installation results in 'karma' is not recognized as an internal or external command

I'm trying to run karma as part as an angular-seed project, after installing karma using npm install -g karma I get: 'karma' is not recognized as an internal or external command, operable program or ...
Liad Livnat's user avatar
  • 7,453
54 votes
9 answers
41k views

karma error 'There is no timestamp for'

Trying to get karma working with requirejs. I don't understand why I am getting all of these errors when running Karma: ERROR: 'There is no timestamp for /base/test/mainSpec.js?bust=1387739317116!' ...
Jeff's user avatar
  • 2,333
52 votes
5 answers
55k views

Injecting dependent services when unit testing AngularJS services

I'm testing service A, but service A depends on service B (i.e. service B is injected into service A). I've seen this question but my case is a bit different because in my opinion it makes more sense ...
Roy Truelove's user avatar
  • 22.2k
48 votes
4 answers
27k views

How to resolve promises in AngularJS, Jasmine 2.0 when there is no $scope to force a digest?

It seems that promises do not resolve in Angular/Jasmine tests unless you force a $scope.$digest(). This is silly IMO but fine, I have that working where applicable (controllers). The situation I'm ...
Terry's user avatar
  • 14.1k
42 votes
4 answers
49k views

Global variables in Karma test runner

I have a global variable defined in my main template, which I use to store information bits from the back end, such as the environment context path. I can't move that variable inside a service. How ...
Mimo's user avatar
  • 6,045
40 votes
11 answers
31k views

How do unit test with angular-translate

I have uses angular translate from here (http://pascalprecht.github.io/angular-translate/) and it's just work fine, but it break my controller's unit test whith Error: Unexpected request: GET scripts/...
bin's user avatar
  • 401
37 votes
4 answers
9k views

How to make travis execute Angular tests on Chrome ("Please set env variable CHROME_BIN")

I'm working on a sample Angular project generated by yeoman. I am able to run karma tests locally (I set system variable CHROME_BIN to point to chromium binary, but this could have been done in more ...
vucalur's user avatar
  • 6,067
22 votes
1 answer
25k views

AngularJS+Jasmine: $httpBackend not working as expected

I'm using Jasmine with Karma to test my app built on Angular. I've to test a service that loads user data and I'm using $httpBackend to mock the responses. However, when I run the test, I got two ...
Wilk's user avatar
  • 7,973
20 votes
1 answer
28k views

Angular unit-test controllers - mocking service inside controller

I have the following situation: controller.js controller('PublishersCtrl',['$scope','APIService','$timeout', function($scope,APIService,$timeout) { APIService.get_publisher_list().then(function(...
Liad Livnat's user avatar
  • 7,453
19 votes
1 answer
24k views

Unexpected request: GET No more request expected at $httpBackend

I have a function in my scope to retrieve the status of my service when the user clicks a button, or when some event are triggered and this function is automatically called. This is my function, ...
Mimo's user avatar
  • 6,045
12 votes
1 answer
3k views

How to deal with angular module's config function when unit testing?

When setting up a unit test suite for an angular application using Karma/Jasmine, is it recommended to include the js with the app module's config function in the test's files? I've read that it is ...
Marplesoft's user avatar
  • 6,140
12 votes
2 answers
13k views

testing keydown events in Jasmine with specific keyCode

I am writing tests for an AngularJS directive which fires events of a <textarea> when certain keys are pressed. It all works fine per my manual testing. I want to be good and have a full unit-...
Michael Bromley's user avatar
9 votes
2 answers
5k views

Is it possible to mix Testacular (Karma) with angular-scenario?

Testacular (now Karma) is awesome, so is angular-scenario. Using them together is proving a challenge however. There is an ANGULAR-SCENARIO-ADAPTER in Testacular, but that breaks simple tests. If you ...
iwein's user avatar
  • 26k
9 votes
1 answer
3k views

Test component with providers

I have a service SoundPanelService which is used in service isolation scenario ( like https://angular.io/guide/hierarchical-dependency-injection#scenario-service-isolation ) @Injectable() export class ...
Developer Marius Žilėnas's user avatar
3 votes
2 answers
2k views

Karma/Istanbul Code Coverage does not find functions and always returns 100%

I am attempting to add Code Coverage for my Karma tests, however although it finds the correct JS files that I'm testing, it does not find the functions inside those files. From what I have read so ...
CD-jS's user avatar
  • 1,135
1 vote
1 answer
17k views

karma TypeError "Cannot read property 'subscribe' of undefined"

While testing a simple component that has a shared service, the following error message appears, and I cannot manage to make it work, I've tried everything! TypeError: Cannot read property '...
SrAxi's user avatar
  • 19.9k
133 votes
8 answers
172k views

Firebase App named '[DEFAULT]' already exists (app/duplicate-app) [duplicate]

Hi I am trying to unit test while developing a simple web with AngularJS + Firebase, but I have a problem defining the spec and trying the test runner myProject/test/spec/main.js : describe('...
parkwookyun's user avatar
  • 1,436
128 votes
7 answers
77k views

Testing service in Angular returns module is not defined

I am trying to run the default service unit test in my project (Taken from the Angular Seed project on GitHub), but I keep getting the error "module is not defined". I have read that it could be ...
Dofs's user avatar
  • 18.4k
89 votes
5 answers
86k views

How can I run tests with a headless browser?

Using: ng test Angular CLI runs the tests by default in Chrome, which is great, but what if I need to run them in a console-only environment (headless browser)? Also it would be nice if I can ...
Francesco Borzi's user avatar
42 votes
5 answers
61k views

RegeneratorRuntime is not defined

I am trying to run Karma-babel-preprocessor and a straight forward ES6 generator: //require('babel/polyfill'); describe("how Generators work", function() { it("will allow generator functions", ...
P.Brian.Mackey's user avatar
36 votes
4 answers
58k views

Mocking $httpBackend - how to handle "Unexpected request, No more request expected"?

I have a Jasmine test that is coded like this: it ("should send correct message to server to get data, and correctly set up scope when receiving it", function(){ $httpBackend.when('GET', 'https:...
onkami's user avatar
  • 9,091
26 votes
1 answer
8k views

AngularJs unit testing memory leaks

as you may already know many of us who have a large quantity of written unit test has met with this not trivially solvable problem. I have around 3500+ unit tests written in the Jasmine syntax ...
S.Klechkovski's user avatar
25 votes
3 answers
28k views

Unit testing a modalInstance controller with Karma / Jasmine

EDIT : Quick & Dirty solution at the end of this post I am using a modal window from AngularUI-Bootstrap in the same way that it is explained on the website, except that I splitted files. ...
Manyuuz's user avatar
  • 278
22 votes
2 answers
23k views

Angular module not available in Karma Jasmine test run

I'm using angular full stack for development, my karma.conf.js file is files: [ 'app/bower_components/jquery/jquery.js', 'app/bower_components/angular/angular.js', 'app/...
sergioramosiker's user avatar
21 votes
1 answer
15k views

How to add jquery to jasmine/angularjs unittests

I have a project which is builded on plain angular.js code. We creates unittest with jasmine. But now we need to grab some 3rd party components (some directives from Angular-Bootstrap), which is also ...
silent_coder's user avatar
  • 6,402
20 votes
4 answers
16k views

Karma Start Fails - HeadlessChrome - ERROR Uncaught [object Object]

I am using Karma to run test on my Angular 4 app. It works locally but when it runs on my host environment (Travis CI) it fails with the following information: INFO [HeadlessChrome 0.0.0 (Ubuntu 0.0....
Justin's user avatar
  • 26.8k

1
2 3 4 5
10