Skip to main content

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.

Filter by
Sorted by
Tagged with
913 votes
22 answers
1.1m 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.6k
366 votes
1 answer
343k views

When to use "chore" as type of commit message? [closed]

What is the use of chore in semantic version control commit messages? Other types like feat or fix are clear, but I don't know when to use "chore". Can anyone provide a couple of examples of ...
Alireza Mirian's user avatar
254 votes
15 answers
217k 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
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
151 votes
9 answers
94k 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,135
134 votes
8 answers
175k 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,446
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.7k
127 votes
9 answers
81k views

Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

I'm developing a github repository (with angular 7 and angular-cli), and I have some tests with Karma and Jasmine working in the master branch. Now I'm trying to add lazy loading feature, the thing is,...
ismaestro's user avatar
  • 8,137
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
109 votes
4 answers
132k 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
108 votes
9 answers
85k 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
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
101 votes
29 answers
65k 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
97 votes
5 answers
38k views

angular 4 unit testing error `TypeError: ctor is not a constructor`

I am trying to test my route resolver and while testing I got TypeError: ctor is not a constructor and no idea why it happen while typescript compile time no error. TypeError: ctor is not a ...
Aniruddha Das'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
89 votes
5 answers
90k 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
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
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,933
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.3k
79 votes
16 answers
149k views

Angular 6 Unit Tests: An error was thrown in afterAll\nReferenceError: Can't find variable: $ thrown

When running my unit tests, from time to time, even if they pass, at the end of all the tests running, I will get the following error. On my Jenkins CI build running PhantomJS: .PhantomJS 2.1.1 (...
Oisin's user avatar
  • 2,182
77 votes
11 answers
136k 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,075
75 votes
5 answers
40k views

View Karma Test Output in a Browser?

I'm new to Karma, but I'm wondering how to view its output in a browser (much like the way one interacts with Jasmine, when a runner.html file is present). I watched the introductory screencast and I ...
blaster's user avatar
  • 8,906
73 votes
9 answers
83k views

How to debug Karma tests in Visual Studio Code?

I want to debug Karma tests in VS Code but I did not find out how. Is there any way to do that or will I have to use another IDE (WebStorm)?
geo's user avatar
  • 2,373
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,603
70 votes
9 answers
45k views

karma command not found when karma already installed

I used node.js to install karma. My first try failed when running the following command on Terminal: npm install -g karma That failed so I decided to use: sudo npm install -g karma After ...
iChido's user avatar
  • 4,444
69 votes
14 answers
72k views

Testing Angular component with unsubscribe Error during cleanup of component

I'm testing a component which subscribe router params. Every test pass and everything works fine. But if I look in the console, I can see an error: Error during cleanup of component ...
BlackHoleGalaxy's user avatar
66 votes
5 answers
33k views

Unit-testing directive controllers in Angular without making controller global

In Vojta Jina's excellent repository where he demonstrates testing of directives, he defines the directive controller outside of the module wrapper. See here: https://github.com/vojtajina/ng-directive-...
Kenneth Lynne's user avatar
64 votes
10 answers
37k views

Angular 2 unit testing - getting error Failed to load 'ng:///DynamicTestModule/module.ngfactory.js'

I have angular 2 webpack application, all webpack,karma configuration created as per angular.io webpack guide. I am not using aot. I am writing jasmine unit test spec to test my components. First I ...
Amit Gaikwad's user avatar
64 votes
10 answers
28k views

Issue running karma task from gulp

I am trying to run karma tests from gulp task and I am getting this error: Error: 1 at formatError (C:\Users\Tim\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:161:10) at Gulp.<anonymous&...
Timur's user avatar
  • 6,698
62 votes
10 answers
48k views

Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)

I have run on my windows console: npm install -g yo grunt-cli bower npm install -g generator-angular yo angular Then I started my project with webstorm and did right click on the karma.conf.js ...
HelloWorld's user avatar
  • 4,812
58 votes
1 answer
25k views

What are the differences between karma reporters?

I am looking at karma's reporter configuration. There are some possible reporters: progress, dots, growl, coverage. I don't find any detailed information explaining each of the options. I tried ...
Aaron Shen's user avatar
  • 8,274
57 votes
14 answers
71k 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,841
57 votes
4 answers
77k views

ReferenceError: module is not defined - Karma/Jasmine configuration with Angular/Laravel app

I have an existing Angular/Laravel app in which Laravel acts as an API to the angular frontend serving only JSON data. The page that loads the angular app, index.php, is currently served by Laravel. ...
Raphael Rafatpanah's user avatar
56 votes
6 answers
52k views

karma test runner detailed test report in console

I just started with unit test my angular app with karma. Everything working as expected Chrome 26.0 (Windows): Executed 1 of 1 Chrome 26.0 (Windows): Executed 1 of 1 SUCCESS (0.878 secs / 0.112 ...
Amitava's user avatar
  • 5,063
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,343
53 votes
2 answers
44k 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
53 votes
4 answers
30k views

How can I get a list of passing tests from karma runner suite?

When I run karma on my webapp, I only get generic messages like tests passed - is there a way to get a list of passing tests? How do I get more verbose output? I cannot find this anywhere in the ...
Amit Erandole's user avatar
53 votes
2 answers
11k views

Why are my AngularJS, Karma / Jasmine tests running so slowly?

I have some simple karma / jasmine unit-tests that run against an angularjs app. I use the latest version of Chrome and run my tests from within the WebStorm IDE. Sometimes the test suite runs very ...
biofractal's user avatar
  • 19.1k
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.3k
52 votes
2 answers
57k views

TypeError: expect(...).to.be is not a function

I am configuring my Karma amd mocha framework with grunt in my project. When I am running karma start I am getting below-mentioned error. I am getting this error in my console while running command : ...
FrontEnd Expert's user avatar
51 votes
14 answers
63k views

Karma not running unit tests due to "No captured browser" message

I'm trying to set up Karma to run AngularJS unit tests using Jasmine, but I can't get the tests to run. I'm sure I'm overlooking something simple. I'm running this on a Windows 7 machine with Node.js ...
levelnis's user avatar
  • 7,685
50 votes
4 answers
31k views

debug in browser using testacular (now karma)

I am trying to figure out the best way to debug my unit tests when I break them. Typically in previous test environments I could just run the tests in the browser and breakpoint the test, or the code ...
Lucas's user avatar
  • 3,423
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
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.2k
47 votes
2 answers
22k views

What should I use instead of fit and fdescribe in Jasmine 3?

I get the error: ERROR: 'DEPRECATION: fit and fdescribe will cause your suite to report an 'incomplete' status in Jasmine 3.0' I did a RTFM for Jasmine 3.0 but it did not mention anything about ...
heldt's user avatar
  • 4,246
46 votes
5 answers
30k views

How to get better test reports in the console?

I have a fairly simple karma.config.js file basePath = '../'; files = [ JASMINE, JASMINE_ADAPTER, 'js/lib/angular*.js', 'test/lib/angular/angular-mocks.js', 'js/**/*.js', 'test/unit/**/*....
blockloop's user avatar
  • 5,705
46 votes
6 answers
47k views

Include dependencies in Karma test file for Angular app?

I am trying to get started with Karma tests, adding them to an existing Angular app. This is my main app definition file: angular .module('myApp', [ 'ngRoute', 'moduleAdherence' ]); ...
Richard's user avatar
  • 64.8k
46 votes
3 answers
24k views

Expect not toThrow function with arguments - Jasmine

I have function that gets 3 arguments. I want to check that this function not throwing an error. I did something like this: expect(myFunc).not.toThrow(); The problem is myFunc need to get arguments. ...
Sagie's user avatar
  • 1,064
45 votes
3 answers
10k views

Is it possible to set up travis to run tests for several languages?

I have a rails project and am running tests for my JavaScript test (Jasmine) through Karma .travis.yml file language: ruby rvm: - 2.0.0 script: - RAILS_ENV=test bundle exec rake --trace db:...
K-Yo's user avatar
  • 1,270
45 votes
3 answers
3k views

Jasmine Runs Test Three Times

I am running Karma/Jasmine/Angular 2.0 tests on my development box. Just recently, Jasmine on my development box decided to start running my tests three times. Yes, exactly three times, every time. On ...
Oliver Spryn's user avatar
  • 17.2k

1
2 3 4 5
93