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

How could I get DefinePlugin to work with karma/istanbul?

I'm using karma to run tests on my code, and they all work fine, but when I add nyc with babel-plugin-__coverage__, I get: ReferenceError: Can't find variable: __DEVELOPMENT__. However, this variable is set in my webpack.config.js: plugins.push(new…
Dec Sander
  • 949
  • 7
  • 5
2
votes
1 answer

Failing to run tests using Karma

I am setting up Karma to simplify unit tests in a legacy project. The problem is, I am getting an error You need to include some adapter that implements __karma__.start method!. As I have found, this is a very non-specific error, so I am at a loss…
azangru
  • 2,364
  • 5
  • 24
  • 47
2
votes
1 answer

Angularjs/Karma: Uncaught ReferenceError: inject is not defined

I got this service angular.module('common.utils', []) .service('Timer', function () { function Timer() { var start = new Date(); return function () { return (new Date()).getTime() - start.getTime(); }; } …
haki
  • 8,571
  • 12
  • 51
  • 101
2
votes
1 answer

Promise .then not triggering when using Karma + Jasmine + PhantomJs?

My unit test is not working hitting the then function for some reason. Here is the test code. describe("Basic promise test", () => { it("should trigger .then function", () => { var mock = jasmine.createSpy('some method'); var…
supersan
  • 4,328
  • 1
  • 34
  • 51
2
votes
1 answer

How to karma test .config where $httpProvider is used in a service layer?

This is how my service looks like (function(){ 'use strict'; angular.module('gls.service', []) .config(config) .service('popup', popup) .service('API', api); /* Config */ config.$inject =…
Shabnam
  • 27
  • 5
2
votes
1 answer

Angular2 and webpack, component require sass breaks unit tests

I'm currently starting on a new project using Angular2, Sass, Webpack, writing tests and running them Gulp/Karma. Unfortunately however once I started requiring my Sass files in the components my unit tests broke. I've seen similar reference to…
Sean
  • 210
  • 1
  • 14
2
votes
0 answers

Karma & PhantomJS are not running reliable on TFS

I have a .NET Project with an Angular Frontend building on a TFS Server. I've set up a gulp task for CI which starts karma with the singleRun flag set and PhantomJS as a browser. This works most of the time but sometimes it isn't running the…
Max Jöhnk
  • 93
  • 8
2
votes
1 answer

"before each" hook: workFn error

I am running my tests with karma and phantom, Also I'm using mocha and sinon and tests are getting failed with below error: EditResourceCategoryDialogTest EditResourceCategoryDialogController "before each" hook: workFn Error: [$injector:modulerr]…
Ranjit Kumar
  • 273
  • 2
  • 14
2
votes
0 answers

Angular2 karma error when using fixture.detectChages()

I'm trying write unit test for the component. Since I have @ViewChild elements in it I want to use TestComponentBuilder, it('should close modal', async(inject([TestComponentBuilder], (tcb) => { tcb.createAsync(UploadImage).then((fixture:…
renchan
  • 499
  • 5
  • 23
2
votes
0 answers

Testing ViewHistory in Ionic

I have a very simple app showing a login screen and a dashboard. When the login is successful the app navigates to the dashboard. In this state, a back navigation (android) should not go back to the login screen. This all works fine using the…
Stefan
  • 957
  • 1
  • 10
  • 29
2
votes
1 answer

Karma error - Expected undefined to be defined

I want to unit test my controller. I started with basic test assertions of expect API. But I am facing challenge in mocking scope methods inside a conditional check. I am getting an undefined error since it is not available under scope, only the…
RVR
  • 97
  • 2
  • 13
2
votes
0 answers

Fixture.detectChanges behaves in a strange way when I add service to the constructor

I have a parent component: @Component({ selector: 'parent-component', directives: [I18nDirective, child-component], template: require('./parent.component.html'), styles: [require('./parent.component.scss')], }) export class ParentComponent…
adam nowak
  • 715
  • 1
  • 8
  • 15
2
votes
1 answer

spyOn method in constructor with jasmine

I want to spyOn a promise and fake that promise in my unit test but the problem is that if I run first the contructor that the problem that he first run the promise and then run the Spyon. But when i first run the spyOn and then the constructor it…
mbakker1996
  • 308
  • 1
  • 5
  • 15
2
votes
0 answers

karma-webpack-tape: Show Line Number when Test Fails

As the title implies, I want to be able to see the line number when a test fails in my suite. I'm relying on the karma-tap plugin, the tap framework, and dots reporter. A little context: source-maps are working properly, so exceptions thrown in a…
ucileamarn
  • 43
  • 5
2
votes
0 answers

Read json config files during karma unit testing

I've mostly got my unit tests working but I'm getting stuck when the application tries to load some JSON files from the app directory. I get an error: Error: Unexpected request: GET scripts/config/getSomeConfig.json I could use…
Marko
  • 68,081
  • 26
  • 118
  • 153
1 2 3
99
100