All Questions
Tagged with angular unit-testing
4,190
questions
-2
votes
1
answer
27
views
ng test for specific module fails [closed]
Running ng test for unit tests set to a specific module fails because it includes tests from other modules.
karma version
folder structure
Image of 'test.ts' file where the test case need to be ...
0
votes
1
answer
29
views
Angular Karma/Jasmine Unit Test Cannot Read Properties Of Undefined Readin imageUrl
I have been tackling an error for a couple of days in my unit testing. Everything I have tried thus far from my research does not seem to resolve the issue. Three of my components are failing unit ...
0
votes
1
answer
28
views
Angular Unit Test - Mocking a function on a property
Updating with some new attempts
I've tried several different approaches, and I'm obviously missing something fundamental on how to avoid this error and mock out this function. I've updated the mock ...
1
vote
1
answer
31
views
Angular Unit Testing - Errors on Testing Promise Rejection
I'm trying to make sure the catch block of a function on my service is covered, and I just can't quite get it to work.
I've tried a couple of different ways. In version 1, it seems cleaner but I don't ...
1
vote
2
answers
46
views
Angular Unit Testing Service - Property in service constructor not using value from spyOnProperty
I'm trying to write a negative test for my AuthService that a property in the constructor is set to null if nothing is returned from angularFireAuth. The positive side of this test case is working, ...
1
vote
1
answer
40
views
Angular Unit Testing - Setting a Property in Mock to Null (spyOnProperty)
I'm having trouble doing a negative test of an ngIf statement that looks at a property on my authService.
I have a mock provider already, and the positive version of this test works great. I can see ...
0
votes
0
answers
25
views
spec.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property in angular test
Recently I upgraded the angular version from 8 to 14, ng serve and ng builds running fine, while I run unit test cases(ng test), it gives us an error -> spec.ts is missing from the TypeScript ...
1
vote
1
answer
20
views
Angular test how to mock an imported const
I have an angular service being tested, which import a const from another file
import { environment } from "../environments/environment";
The environment.ts is like
export const environment ...
0
votes
0
answers
22
views
angular unit test coverage report html is empty
Somehow I have an empty index.html in coverage report folder after running "ng test --code-coverage":
I tried once and saw the report html file is filled with each component coverage but ...
1
vote
0
answers
35
views
Angular 17 AngularFireModule Not Provided in AppModule' When Executing FirestoreDataService Test Cases with Jasmine and Karma
jasmin-karma error image ,
import module image
import { ErrorHandler } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { getFirestore, provideFirestore } from '@angular/...
1
vote
1
answer
34
views
Angular testing with material querySelector returns always null
I have an Angular project running with material ui.
I am writing unit tests and my problem is to access DOM elements.
My component.spec.ts runs fine, except I cannot access HTML elements inside mat-...
1
vote
1
answer
45
views
How to mock variables in a template in a Jest unit test for an Angular application?
I meet a problem in a jest unit test.
the code for the html looks jest like this:
<ng-container *ngVar="personFacade.personInfo$ | async as personInfo">
@if (personInfo.active){
<...
0
votes
0
answers
26
views
Angular Jasmine Unit Testing How To Handle CORS Policy Error
I'm having an issue with CORS blocking on my unit test using Jasmine, I understand the
issue but I'm not sure how to fix it. I have handle the CORS issue with my application on the backend ...
0
votes
1
answer
39
views
Mocking AngularFireAuth for angular service unit testing
I created a service to handle all of my authentication calls to angularFireAuth, but the basic toBeTruthy assertion is hitting an injector error for angularFireAuth. I solved this for several other ...
1
vote
1
answer
35
views
Angular unit test failed due to data in HTML NgModel binded to a service's property not updated
I have a LoginPageComponent with email and password fields whose values areNgModel binded to LoginServices's property loginInfo. LoginPageComponent also has Login button, which is disabled when ...