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.

Basic functionality

For all browsers connected to Karma's web server, source code is executed directly against test code. Developers receive the results of the tests on the command line with the ability to see which tests passed or failed for each browser.

Notice that Karma is only a test-runner, meaning it does not do testing itself. It runs tests implemented in some other test framework (e.g. Jasmine, QUnit, or Mocha).

Features

  • It can launch and run the test through real browsers.
  • It monitors file update on disk, and can instantly re-run required test giving very quick feedback on changes.
4608 questions
825
votes
20 answers

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 (I guess I can put it as a comment right in the…
iLemming
  • 34,477
  • 60
  • 195
  • 309
314
votes
2 answers

When to use "chore" as type of commit message?

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 its use? Another maybe not related question: What's the…
244
votes
15 answers

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 whole suite on each save, which is a bit slow when…
Elliot Larson
  • 10,669
  • 5
  • 38
  • 57
194
votes
10 answers

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's one of them: Error: Attempt to unlock…
TJ Kirchner
  • 4,321
  • 6
  • 24
  • 26
129
votes
8 answers

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

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('Controller: MainCtrl', function() { var MainCtrl,…
parkwookyun
  • 1,396
  • 2
  • 8
  • 9
128
votes
7 answers

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 something to do with the order of the referenced…
Dofs
  • 17,737
  • 28
  • 75
  • 123
127
votes
9 answers

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, that the tests that before passed, now they do…
ismaestro
  • 7,561
  • 8
  • 37
  • 50
124
votes
7 answers

"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 installing all dependencies from NPM, the unit tests run…
dawsonc623
  • 1,841
  • 2
  • 16
  • 26
110
votes
8 answers

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 batch file. when i'm trying to run test.bat from…
Liad Livnat
  • 7,435
  • 16
  • 60
  • 98
109
votes
4 answers

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 in question... However, what I do want is to be…
Gonçalo Vieira
  • 2,249
  • 2
  • 19
  • 39
105
votes
4 answers

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
  • 19,688
  • 10
  • 46
  • 62
104
votes
9 answers

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 it possible?
user3730696
100
votes
29 answers

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, the browser page is ready, but karma run fails as…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
97
votes
5 answers

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 constructor TypeError: ctor is not a constructor at…
Aniruddha Das
  • 20,520
  • 23
  • 96
  • 132
90
votes
8 answers

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) { elm = angular.element('
1
2 3
99 100