Skip to main content

All Questions

0 votes
1 answer
510 views

How to unit test timer() observable with jasmine marbels

I'm trying in angular application to unit test ngrx effect that introduces some polling logic using timer and maps to some actions depending on the value from some selector. My code is something like ...
AndrewN's user avatar
0 votes
1 answer
22 views

Unit tests for Angular observable to modify observable return value for different test cases

HTML <ng-container *ngIf="configuration$ | async as configuration"> .... </ng-container> TS configuration$ : Observable<Configuration> = this.configService.configuration$;...
shubham_agrawal's user avatar
1 vote
2 answers
1k views

Unit Testing - Mocking a Subject using ng-mocks

I am trying to add unit tests to my angular component which is dependent on a service. The component is subscribing to a flag variable in the service. I am trying to use ng-mocks to mock the service ...
seeker_1234567's user avatar
0 votes
1 answer
689 views

Angular Unit Testing: Access the Observable @Input variable value passed from parent component

I'm new to testing. I'm writing a unit test for an Input variable which is being set in parent compoent. The value is an observable which use forkJoin. parent.component.ts public dataObj$: Observable&...
Nitika Gahlawat's user avatar
1 vote
0 answers
1k views

Angular unit test pipe, map from service - pipe is not a function

I can't get any of my unit tests to run if I use fixture.detectChanges() because of observables I'm initiating in ngOnInit. I've been able to test Observables in other components, but I'm not sure how ...
edc's user avatar
  • 25
1 vote
1 answer
836 views

Angular testing .next on ngOnInit

have this function .next I have to make ONE unit test for: I can't make that red part on imgur work .This is what I tried: describe('ngOnInit', async () => { beforeEach(() => { (component ...
MatrixelGR's user avatar
0 votes
1 answer
165 views

Jasmine - Testing/Spying on a Subject in an Angular component

My component has a Subject<void>, which when emits, calls another function - refresh(). In my unit tests, I need to test this behavior, or more specifically, that the refresh() function is ...
Dust_In_The_Wind's user avatar
-1 votes
1 answer
100 views

Observable returns string by letters (Karma, Angular)

I try to mock http service in Angular tests (Karma). I added something like this is providers array: { provide: service, useValue: { getData: () => new Observable((subscriber) =...
thortineoc's user avatar
5 votes
1 answer
6k views

Angular unit test pipe is not a function when subscribe observable from a service

I'm writing a unit test to subscribe observable from a service. I'm getting pipe is not a function error. I have created a jest spy for fundsListByClientId$ and simply returned the mock data. Please ...
Johnny's user avatar
  • 291
2 votes
2 answers
16k views

Angular unit test, how to test a subject as observable

I am trying to test a subject as observable, but it is not working as expected For simplistic I have removed extra logic inside getService2Test subscribe Below is my function in service class getTest(...
SimpleCoder's user avatar
0 votes
1 answer
1k views

Angular - How to test if an error was thrown from an observable error function

I have this nested subscription in a function: myFunc() { this.userService.isLoggedIn().subscribe(isLoggedIn => { if (isLoggedIn) { this.otherService.post({}).subscribe({ ...
Daniel Tahin's user avatar
0 votes
1 answer
828 views

Jasmine unit testing - mat-Autocomplete filter class

I'm writing jasmine unit tests for an angular app, coverage is pretty good, but struggling to find a good way to test observable filter classes for mat-autocomplete data population. The ts class: ...
YorkshireDevOliver's user avatar
0 votes
1 answer
270 views

How can I test my service in Angular with Jasmine?

I created a service which looks like this: @Injectable({ providedIn: 'root' }) export class NotificationService { private notifications: Notification[] = [] private readonly notifications$...
Daniel Tahin's user avatar
2 votes
0 answers
237 views

Expect error to be thrown out of next handler of observable, testing Angular with Jasmine

In Angular application have a controller with following method onClick(): void { this.http .get('some/endpoint') .subscribe( (response) => { const ...
mimo's user avatar
  • 6,867
0 votes
1 answer
547 views

How to test code block inside observable subscription for Angular service

I have an Angular service method that uses another service for making api call. After the call success and inside of the subscription, I call some methods e.g. notifySucess, emit new value... My ...
Binh's user avatar
  • 396

15 30 50 per page
1
2 3 4 5 6