angular-test Questions

4

Solved

When my components are like this export OldComponent { @input myInput!: string; } I can prepare the unit tests like this: fixture = TestBed.createComponent(OldComponent); component = fixture.comp...
Cerallua asked 7/2 at 6:43

7

Solved

I have a basic angular application , which was working fine. The ng serve and ng test commands were working fine. Recently as part of build automation for different environments , I introduced some...
Berkeleianism asked 27/3, 2020 at 10:1

3

Let's say I have an Angular Component which defines an Observable myObs$ as one of its properties. In one test, given certain conditions, I want to test that myObs$ does not notify. In the logic t...
Garrott asked 30/1, 2019 at 18:15

4

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

4

First example I have got the following test: import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Component } from '@angular/core'; @Component({ template: '<ul...
Lolly asked 16/3, 2019 at 10:28

3

Solved

I'm testing an angular service with Jest. I can to mock my httpClient, but I have a problem it is that I cannot test a url with a parameter (ex: "http://localhost:8080/api/feature/num?id=25663"). ...
Blessed asked 29/1, 2020 at 17:13

3

Solved

Lets say I have a simple module AppModule which has many imports, declarations and providers. Now I want to write a test for a component ListComponent which is located in this module's declaration ...
Borisborja asked 14/2, 2018 at 14:13

7

convert angular 7 project into angular universal while running "ng test" command giving error as "Incomplete: No specs found, , randomized with seed 48751". Tried different ways mention over stacko...

2

I have several components (about,service,dashboard, etc) in which a header component is added. The application is running fine. However, I am getting errors when testing. import { Component } from ...
Berri asked 23/9, 2021 at 11:38

5

I've just finished fixing several warnings on my unit/component tests of my Angular app, that run using ng test (with Karma/Jasmine). This process can be quite time-consuming as it is not always o...
Indoor asked 6/3, 2020 at 15:22

2

Solved

I used ResizeObserver in my component and its works fine. But get such error when running ut: ReferenceError: ResizeObserver is not defined 133 | }); 134 | > 135 | this.resizeObserver = ne...
Antecedence asked 6/1, 2021 at 7:22

13

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

2

I have migrated Angular 4 app to Angular 6 and now Test cases fail with following error message in terminal and it shows success on browser. Also, sometimes test cases pass without showing any erro...
Rival asked 12/8, 2018 at 10:22

1

Solved

After configuring Jest with Angular 14, I'm getting this error: Test suite failed to run TypeError: typescript_1.default.canHaveDecorators is not a function at TypeScriptReflectionHost.getDecorat...
Fremitus asked 18/1, 2023 at 18:35

6

I have checked a lot of articles and answers but I don't seem to find the right way to mock HTTP Requests for my methods. I want to test my frontend application independently from the backend. Here...
Scimitar asked 20/11, 2019 at 9:24

2

Solved

Angular can Query subComponents by Types, which is used in Testing like this: fixture.debugElement.query( By.directive( ComponentType ) ); Now i wanted to make a function which does this for me: i...

5

In my TypeScript app I have a method that return an rxjs Observable which, in a certain case, can return throwError: import { throwError } from 'rxjs'; // ... getSomeData(inputValue): Observable...
Hovercraft asked 5/9, 2019 at 11:41

3

In my Angular 4 component I have something like: constructor(private route: ActivatedRoute) { } ngOnInit() { this.myId = this.route.snapshot.params['myId']; } And I'm trying to create a mock t...
Pedal asked 19/10, 2017 at 13:55

2

I am spying on method emit of EventEmitter in Angular spyOn(answerComponent.answerEmitter, 'emit'); I want to check that emit was called with an argument A but I don't want to check exact match wi...
Zooplasty asked 28/12, 2020 at 12:16

4

Solved

Component: @Component({ selector: 'app-test', templateUrl: './test.component.html' }) export class TestComponent implements OnInit { useCase: string; constructor( private route: ActivatedRou...

3

Solved

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 + '-scopevalue']" class="inline-editor" ...
Secondly asked 22/5, 2018 at 8:43

5

While testing my Angular application I am getting deprecation warnings 'DEPRECATED: DI is instantiating a token "MockLocationStrategy" that inherits its @Injectable decorator but does no...
Condensation asked 21/5, 2021 at 19:39

1

I do have the following beforeEach: beforeEach(() => { fixture = TestBed.createComponent(ApplyComponent); component = fixture.componentInstance; fixture.detectChanges(); store = TestBed.get...
Dispassion asked 13/11, 2019 at 15:51

6

Solved

The application was built on Angular v4 and was gradually updated with every release up until now. Currently we're on Angular v7 and finally the CEO has agreed to write unit test while it wasn't th...
Boult asked 16/7, 2019 at 7:29

2

How test the call on method of private variable ? I must test the call of unsubscribe method when the ngOnDestroy is called. There is my code import { Component, OnInit } from '@angular/core'; im...
Caucus asked 18/1, 2018 at 10:5

© 2022 - 2024 — McMap. All rights reserved.