All Questions
88 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 ...
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$;...
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 ...
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&...
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 ...
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 ...
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 ...
-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) =...
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 ...
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(...
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({
...
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:
...
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$...
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 ...
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 ...