Top "Angular-test" questions

Questions about testing Angular code, addressing either specific issues ("why is this test failing"), test flows ("how to test this async call of my component") or test setup ("how do I mock router in this component test"), integration tests ("how to bypass a proxy to my backend in this angular test"), or possibly test-related questions, such as ("Why does this component work and the test is failing?

Angular2 unit test with @Input()

I've got a component that uses the @Input() annotation on an instance variable and I'm trying to write my unit …

angular typescript unit-testing jasmine angular-test
Angular 6 - NullInjectorError: No provider for HttpClient in unit tests

I am importing and using HttpClient in a service as follows: import { Injectable } from '@angular/core'; import { HttpClient } from …

angular karma-jasmine angular-test
How do I unit test if an element is visible when the *ngIf directive is used using Jasmine in Angular

I have an Angular 6 app and writing some unit tests trying to determine if an element is visible or not …

javascript angular jasmine karma-jasmine angular-test
Angular 2 Testing - Async function call - when to use

When do you use the async function in the TestBed when testing in Angular 2? When do you use this? beforeEach(() =&…

angular unit-testing karma-jasmine angular2-testing angular-test
How do I turn off source maps for Angular 6 ng test?

I am trying to turn off sourcemaps for my tests in Angular 6. I know the sourcemaps switch has been removed, …

angular angular6 angular-cli angular-cli-v6 angular-test
This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid

In my Angular 9 app, I have an abstract class: export abstract class MyAbstractComponent { constructor( protected readonly cd: ChangeDetectorRef, ) { super(); } // ... } and …

angular typescript angular-test angular-ivy angular-dependency-injection
How to mock route.snapshot.params?

In my Angular 4 component I have something like: constructor(private route: ActivatedRoute) { } ngOnInit() { this.myId = this.route.snapshot.params['myId']; } …

angular angular-test
Unit test Angular Material Dialog - How to include MAT_DIALOG_DATA

I am trying to unit test this material dialog to test if the template is rendering the right injected object. …

angular unit-testing karma-jasmine angular-material2 angular-test
Angular component test error: TypeError Cannot read property 'subscribe' of undefined

I have a simple unit test that is done using karma/jasmine on an Angular 6 component. From the pluralsight course …

angular unit-testing jasmine angular-test