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.
4451 questions
557
votes
12 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
  • 30,282
  • 53
  • 181
  • 302
193
votes
9 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,269
  • 6
  • 22
  • 26
185
votes
10 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
  • 9,039
  • 4
  • 33
  • 55
149
votes
1 answer

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…
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
  • 13,655
  • 25
  • 72
  • 120
116
votes
8 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
  • 5,270
  • 6
  • 31
  • 45
109
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,055
  • 16
  • 55
  • 92
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,590
  • 10
  • 44
  • 62
98
votes
3 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,089
  • 1
  • 16
  • 39
95
votes
26 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
  • 266,361
  • 143
  • 616
  • 705
94
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
  • 14,517
  • 13
  • 83
  • 111
87
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,…
87
votes
7 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('
87
votes
2 answers

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
  • 18,671
  • 22
  • 89
  • 141
85
votes
8 answers

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, and returns that converted object. That's it. For…
Aaronius
  • 4,872
  • 6
  • 29
  • 39
1
2 3
99 100