All Questions
260
questions
1
vote
1
answer
117
views
TS2305: Module '@angular/core/testing' has no exported member async
I updated angular version from 17 to 18 and because of which some modules are no longer supporter especially in spec.ts files while importing them.
Like async from @angular/core/testing and **...
1
vote
0
answers
30
views
Nested ViewChilds in Angular component, unit testing
I have a parent component, where in my template i have button :
<button
actions
data-cy="appointment-creation-calendar"
*ngIf="tabIndex === 1"
[...
1
vote
1
answer
58
views
Angular unit test component's @Input. Change value detection
I have a simple scenario where (angular 17.3) I'm trying to test is the component reacts when the input property is changed.
I have a property passed from a parent component where it comes as @Input ...
1
vote
0
answers
66
views
Injection of mocked service fails for nested service when testing an Angular app with ng-mocks
We started using the very nice ng-mocks for our test, but I have trouble getting the mock injection right for this case:
OurService that uses the DatetimeService and NumberFormatterService.
...
0
votes
0
answers
44
views
Angular Modal Service Failed "RangeError: Maximum Call Stack Size exceed" issue
Using below service in my project and unit testing failed due to Range Error and where I used this service that component also failed unit test.
Modal.service.ts
import { DOCUMENT } from '@angular/...
0
votes
0
answers
42
views
Testing on change event input box in Angular
I am trying to test a method that is triggered when you type in an input box. How do I trigger the change event and pass a value to the input? Say for example I just want to test is onAmountChange ...
-1
votes
1
answer
145
views
Getting Error Cannot read properties of undefined (reading 'subscribe') in Unit testing
I'm trying to write a Unit test for my component in angular but when it calls an Api it getting undefine from reponse and i don't know how to handle this because it's my first time writing a unit test ...
2
votes
1
answer
54
views
How to test response with error in Jasmine?
This is part of the code I want to test:
ngOnChanges() {
this.searchCriteria$ = this.bookingService.getSearchCriteria(this.booking.id).pipe(
catchError((err) => {
this.error$ = of(err);
...
-1
votes
1
answer
34
views
Not able to test subscribe method in angular
My ts file has a subscribe method in ngAfterViewInit() which is added below. So while writing test case and doing debugging its not coming inside subscribe method and setting that mock data. So for ...
1
vote
1
answer
458
views
Angular Typescript Jest unit test is not failing for console errors or unknown elements
I have a jest unit test in my Angular Typescript project that will not fail if one of the components (ex. mat-paginator if I don't import MatPaginatorModule in the test's configureTestingModule) or ...
0
votes
1
answer
1k
views
Please set env variable CHROME_BIN | Windows
karma can not start chrome - here is error
I tried to ng test for my angular application and I get this result. I tried to use this command in cmd:
SET CHROME_BIN = "C:\Program Files (x86)\Google\...
1
vote
1
answer
164
views
How to make DOM assertions using Angular Material's component harnesses?
I'm trying to understand how to properly use Angular's Component Harnesses in my tests. I'm able to manipulate components using the harness, but I don't understand how to make assertions about their ...
2
votes
0
answers
103
views
How to cover service.map in Angular Test?
I'm new to Angular UT.
I find it difficult to cover this.service.map on my current test. This is the method I want to test:
validateSupervisorLevel(eid = '', supervisorLevel: number): AsyncValidatorFn ...
1
vote
2
answers
498
views
Angular Jest service test fail if service has a contructor
Angular test fail when i try to test service that contains contructor. No matter if constructor has dependencies or it's empty.
Hi, I have an issue with testing angular app using jest. When I try to ...
0
votes
1
answer
133
views
Unit testing a compnent that is getting data from Angular Replay Subject
I have this service called EmployeeService where I am using Angular's ReplaySubject to get data from an api. I'm subcribing to this ReplaySubject from another component which I am trying to test now. ...