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...

Unable to run Coverage with Karma

I'm trying to run coverage with karma, and I get the warning: WARN [preprocess]: Can not load "coverage", it is not registered! I thought I installed coverage when I ran 'npm install -g...

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',...

Karma error - Chrome have not captured in 60000 ms, killing

DEBUG LOG: E:\Projects\abb\Projects\WebApp\abb.web>karma start DEBUG [plugin]: Loading karma-* from E:\Projects\abb\Projects\WebApp\abb .web\node_modules DEBUG [plugin]: Loading plugin...

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...

Karma run single test

I use karma for run tests. I have many tests and run all tests is very slow process. I want to run only single test in order to spend less time, because all test runs about 10 minutes. Is it...

Karma: uncaught ReferenceError $ is not defined

I have seen many other answers on this site but none of them worked for me. The problem: I need to load jQuery with an URL, not with a local path; and I think I can't add thoose to "files" on...

Karma-Jasmine: Unexpected request: GET ... No more request expected

THE SITUATION: I am testing two different http calls in my AngularJs app. There is a strange behavior. If i test each one separately, with the other temporary commented out (in the controller and...

Karma reload debug.html on test file changes

When running Karma with autoWatch: true and singleRun: false, any change to my unit test files causes the tests to be re-run, and refreshes the Karma webpage at localhost:9876: The problem is...

How do you know which components to import when unit testing?

I am using Angular2 (2.1.0) final release. I was importing all components via AppModule when unit testing using ... beforeEach(async(() => { TestBed.configureTestingModule({ imports:...

Istanbul instrumenter loader can not find source map for Angular2 component.

I'm trying to put up angular2 scaffolding using karma, jasmine, webpack by following various sources from online to get a deeper understanding. I'm using istanbul-instrumenter-loader for karma...

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...

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...

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...

In what order does Karma run its tests?

I'm running Karma tests through jenkins. Normally when a test fails it shows the test name and the number of the test but in some instances it just shows the number. Does Karma run its tests in a...

Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation

This is my spec file: import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from...

Exclude scss files from karma

I want karma to completely ignore/not care/be completely oblivious to style files. I've got the following in my webpack config, which causes webpack to not import the files during build. plugins:...

PhantomJS 2.1.1 Error

I can't run my test with karma and phantomJS because of this error: PhantomJS 2.1.1 (Windows 7.0.0) ERROR SyntaxError: Use of reserved word 'class' Here is my config...

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...

Jasmin + karma: "Error: Unexpected value 'HttpClient' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation."

I'm using jasmine as a test framework and karma as a test runner. I'm trying to create an HttpClient object so I could create a service that as a depedency to this...

Karma: use Windows' Chrome from WSL

I am trying to launch karma from WSL using the Windows version of Google Chrome. In the karma.conf.js I simply use the Chrome browser: [...], browsers: ['Chrome'], [...] And I export the...

How do I debug errors from karma-server?

I'm using karma along with karma-typescript (but this isn't an Angular project, so I'm not using angular-cli). About half of my test runs generate an error after all of the tests have passed, and...

Mocking DOCUMENT in Angular/Karma

How do you mock DOCUMENT (the shadow representation of an HTMLDocument) in Angular? The implementation is using this in the constructor: @Inject(DOCUMENT) private document: Document After...

Karma can not load browser launcher

[launcher]: Cannot load browser "FireFox": it is not registered! Perhaps you are missing some plugin? I've followed all the steps ( that I know of ) : npm install karma-firefox-launcher...

Karma: property does not have access type get

I have an error in my Karma tests in my Angular application. The error is when I run my tests: Failed: Property activePropertyChanged does not have access type get I'm trying to mock a service...

include option for ng test is not working

I am trying to run unit tests using Karma and Jasmine using the ng test. when I issue the following command: ng test --watch=false --code-coverage --main...

Karma , Istanbul - code coverage report Unknown% ( 0/0 )

I'm getting this Coverage Summary =============================== Coverage summary =============================== Statements : Unknown% ( 0/0 ) Branches : Unknown% ( 0/0 ) Functions :...

Failed: Cannot read property 'setValue' of undefined for a login test

I have written the following tests: import { DebugElement } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { AuthenticationService }...

ERROR [karma]: { inspect: [Function: inspect] } while ng test on my Mac

I will appreciate any help... I'm trying to run my Unit Test (Karma/Jasmin) on a Mac where my local development environment is installed. I'm facing an issue while attempting to run ng test this...

Angular 11 > 12 TypeError: Cannot read property 'match' of undefined

I have just upgraded my angular app from Angular 11 to 12 using the steps provided from https://update.angular.io/. I am able to compile and run. However, when I run npm test, I got the following...