Category "karma-jasmine"

Angular Unit Test for Http Error Interceptor not working

I have following http error interceptor: @Injectable() export class HttpErrorInterceptor implements HttpInterceptor { constructor(private util: UtilService,

Angular v12 - Unit Test - [ERROR] No specs found

After developing my Angular application I would like to run unit tests with Karma and Jasmine. I haven't written any unit-tests yet, but trying to run the defau

Angular/Testing unit: Failed: The pipe 'async' could not be found

When I run the ng test on this spec file it fail with this error: Failed: The pipe 'async' could not be found! I have tried to fakesync() the test and still the

In angular material table , on a button click it should filter data which are older than 3 months

I had angular material table which contain a column that shows data using this I need to filter data which are older than 3 months

Spy on the result of an Observable Subscription with Jasmine

I am Jasmine unit testing an angular component, which uses Observables. My component has this lifecycle hook that I am testing: ngOnInit() { this.dataService.

Is there any shortcut/command available to skip karma tests? like -DskipTests for Maven

I have created Maven Web application and I generally use mvn clean install So it execute npm install command as its one of the execution goal and then it ru

How to create new event for unit testing in Angular 2?

Hi I am writing unit test case for my angular code. I am trying to update textbox in gridview. Below is my gridview code. <input *ngIf="editing[rowIndex + '

Angular e2e - should render title in a h1 tag

I am developing my own website. I am new to Angular and just based on learing and online posts, I started developing my website. While running tests, I faced an

Having problems with testing angular app / ERROR: 'DEPRECATION: describe with no children (describe() or it())

After runned my test with this artist-detail.spec.ts import { HttpClientModule } from '@angular/common/http'; import { ComponentFixture, TestBed } from '@angula

Unit test for Button with disable

I am trying to write a unit test for a button that has disabled assigned to a boolean. html looks like: <button *ngIf="!data" id="createBtn" mat-button c

angular unit tests - start Chrome after successful build (taking long time)

On some machines building the Angular app takes more then 2*60s (default timeout for Chrome started by Karma to catch the content). Is there a way to force Kar

Angular Mock ActivatedRoute using Snapshot and ParamMap

I'm using this, from here: constructor(private heroService: HeroService, private activatedRoute: ActivatedRoute) { } ngOnInit() { const heroId = this.

Angular test fails to run with ChromeHeadlessCI in Github Action

I bootstrap a simple Angular (v10.1) app and create Github action workflow as below. Note that I have configured test to run with recommended configurations as

How to write unit test for a service having breakpoint observer?

I have a service having a breakpoint observer. But how we can trigger window resize event for breakpoint observer to cover all branch and lines. export class B

How to write unit test for a service having breakpoint observer?

I have a service having a breakpoint observer. But how we can trigger window resize event for breakpoint observer to cover all branch and lines. export class B

Mocking base class in a unit test for Angular 2

I'm trying to write a unit test to see if the base class method gets called Here is the base class export abstract class Animal{ protected eatFood() {

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 P

How to test a component with a renderer in the constructor

Consider this code: import { Component, OnInit, Renderer, OnDestroy } from '@angular/core'; import { TranslateService } from 'ng2-translat

Angular/Karma unit test error "1 timer(s) still in the queue"

This is hardly first encounter I've had with "1 timer(s) still in the queue", but usually I find some way to use tick() or detectChanges(), etc., to get out of