Questions tagged [angular-jest]
27 questions
0
votes
0 answers
angular v12 with jest, upgrade to angular v13 breaks test execution
I upgraded my angular cli based Angular app v12 to v13 and all of a sudden deprecated warning which I was getting in v12 reached to the breaking point.
when I run my tests I gets the following error.
An unhandled exception occurred: NOT SUPPORTED:…

d-man
- 57,473
- 85
- 212
- 296
0
votes
0 answers
Angular 13 upgrade - JEST issue
I am upgrading my angular app from v12 to v13. It gets compiled without issues. Even ng build works fine. But the unit tests that were previously passed successfully using JEST are failing now.
Below is my package.json
"dependencies": {
…

GokuSS3
- 123
- 1
- 11
0
votes
0 answers
Mock @ViewChild using Jest Angular
I am using Jest version 28.1.0 and Angular version 12.2.17. I want to mock below code but unable to do it. Please guide me how can I mock @ViewChild.
@ViewChild(ChildComponent) childComponent!: ChildComponent;
apply(): void {
…

Anna
- 1,669
- 7
- 38
- 63
0
votes
0 answers
Angular Jest - test service with dependency on another service and so on
I'm starting with Jest and Unit test. I need to create unit tests for an already existing big application on angular 11, and I start by testing services.
Here is my BaseService. Most of my other services expends from this one.
@Injectable({
…

Leinox
- 279
- 1
- 3
- 10
0
votes
2 answers
Angular CDK Overlay - Mocking overlay component in unit test
I've created an offcanvas component for angular, but I can't get my unit tests to work.
Here's the failing unit test (offcanvas-host.component):
describe('BsOffcanvasHostComponent', () => {
let component: BsOffcanvasTestComponent;
let fixture:…

Pieterjan
- 2,738
- 4
- 28
- 55
0
votes
1 answer
How to solve error "Can't bind to 'ngIf' since it isn't a known property of 'span'"
I am developing unit tests in an Angular 12 app with the help of Jest testing framework. Now there is a console error "Can't bind to 'ngIf' since it isn't a known property of 'span'" within child component after test run.
By the way, the data which…

johannesMatevosyan
- 1,974
- 2
- 30
- 40
0
votes
1 answer
If 'app-user' is an Angular component and it has 'InwelcomeMsg' input, then verify that it is part of this module
I am getting an error as follows when i test the child component:
1. If 'app-user' is an Angular component and it has 'InwelcomeMsg' input, then verify that it is part of this module.
on testing the component. i am using testing-library for angular…

user2024080
- 1
- 14
- 56
- 96
0
votes
1 answer
Unable to cover code in async function in Angualr and Jest: Expected number of calls: >= 1 Received number of calls: 0
I have an async method where I am calling 2 other methods that return promise. I am mocking uploadData and addOrEdit to return a resolved promise. When I call the uploadFile, both uploadData and addOrEdit methods get covered, but the expectation,…

Pritam Bohra
- 3,912
- 8
- 41
- 72
0
votes
1 answer
Invalid or unexpected token while Jest migration
I'm migrating my project from Karma-Jasmine to Jest.
But I'm getting the following error. It seems I'm missing some configuration.
The error points out to constructor(@Inject('env') env: IEnvironment, line from the service which is imported in the…

Kalpesh Bharambe
- 21
- 8
0
votes
1 answer
How to mock Angular external Javascript object
I have an angular application which only purpose is to build @angular/elements (no index.html, no app.component, etc.).
Those elements are used in an .NET Mvc app which provides two kind of things I'm trying to mock in my unit tests:
1 - External…

Etienne Ghiringhelli
- 13
- 4
0
votes
1 answer
Directive unit testing fails
I am using jest.js for testing with my angular app. here is the directive I use in html:
0
votes
0 answers
angular jest, Testing effect throw Unhandled error
Here is my effect spec file: when i run this
import { TestBed } from '@angular/core/testing';
import { Actions } from '@ngrx/effects';
import { provideMockActions } from '@ngrx/effects/testing';
import { cold, hot, getTestScheduler } from…

3gwebtrain
- 14,640
- 25
- 121
- 247