Category "karma-jasmine"

What I am doing wrong when testing this method?

I am trying to test a method within a service that performs an http post. I have mock the service in my spec.ts and all seems correct for me, but the boolean va

Karma tests: Cancelling of Subscription in finalize does not work

I have this scenario: there is a service taking data from BE. Every call of this service (its method) is subscribed and this subscription is saved to Subscripti

Angular 13 and Karma: ReferenceError: global is not defined

i know there are many posts on this subject but nothing has helped so far. Such things like (window as any).global = window in polyfills.ts didn't work Angular:

Angular karma code coverage report folder not generated

When I run ng test --code-coverage, The coverage report is sometimes not generating, sometimes it is generating so I'm unable to verify the coverage statement a

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() {