Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

How to config karma with puppeter in docker?

I need puppeter to test some specifics pdf cenarios and stuffs. currently my karmaConfig is: module.exports = function (config) { const process = require("process"); process.env....
Percy22's user avatar
  • 63
1 vote
2 answers
50 views

Angular 18 httpClient testing expects

I just migrated my app angular version from angular 15 to angular 18. The app is running ok but my tests starts to fail when i switch the deprecated versions of httpClientModule to provideHttpClient(...
Percy22's user avatar
  • 63
0 votes
0 answers
29 views

angular 17 + jasmine + karma: Uncaught ReferenceError: require is not defined

Just like the title says, the require is not defined error keeps popping up and is preventing me from processing my unit test. Here's my karma.conf.js file: // Karma configuration file, see link for ...
Terry Windwalker's user avatar
1 vote
1 answer
66 views

Overriding dependency directive after migrating to angular standalone components

I began migrating my angular 18 application to standalone components and I've run into issues overriding various imports. I'm using Angular 18, Material, NGMocks, Spectator (as testbed replacement) ...
Martinspire's user avatar
0 votes
0 answers
90 views

Reading from "node:fs/promises" is not handled by plugins (Unhandled scheme) in Angular 17

The application works all good when running ng serve and ng build. But when I run ng test, it throws the following errors: node:fs/promises - Error: Module build failed: UnhandledSchemeError: Reading ...
Terry Windwalker's user avatar
1 vote
1 answer
35 views

Jasmine test: Expected spy updateValueAndValidity to have been called

I have an Angular component with this method: deleteRule(index: number): void { this.rules = this.formGroup.get('rules') as FormArray; if (this.rules.length > 1) { this.rules....
CJe's user avatar
  • 1,970
0 votes
0 answers
29 views

How to cover with unit test a settimeout in a event listener in angular method?

Using jasmine and karma, I can pass the unit test using fake async and using a real event, but the coverage is not correct, the settimeout call back is ignored. @Component({ selector: 'slider', ...
Tabares's user avatar
  • 4,277
1 vote
1 answer
103 views

Unit Testing Angular: Cannot read properties of undefined (reading 'ɵcmp')

I'm trying to develop a test for a component of an Angular (v18) application. The component is standalone and the file spec file is the autogenerated one, I added only the services that the component ...
Valentina Maronese's user avatar
1 vote
2 answers
39 views

How to test observable that emits multiple times on subscription in jasmine angular framework

I am having a service product.service.ts class ProductService { public product$: Observable<string> = from(['prod1','prod2','prod3','prod4']); <other methods goes here...> } I want to ...
aagash's user avatar
  • 13
0 votes
1 answer
22 views

Error in default test CAse:Cannot read properties of undefined (reading 'username')

Getting Error in default test case. My component has a Reactive form with NgModel binding to display Data as well as read the updated data in the form. While executing the spec while, I am getting ...
sejal purohit's user avatar
0 votes
0 answers
35 views

Transloco loader module for testing angular... Can't programmatically import translations?

Kind of new to Transloco, but I got this module working to test my components: import { TranslocoTestingModule, TranslocoTestingOptions } from '@jsverse/transloco'; import { SUPPORTED_LANGUAGES } ...
jugglervr's user avatar
  • 165
1 vote
1 answer
38 views

How to trigger a service call and validate output length in a test with jasmine?

Problem (1) I am not able to find a way to trigger a service call in unit test which should be triggered when input is given. (2)The length of output can be determined based on the input and the ...
prachi bhamodre's user avatar
2 votes
2 answers
47 views

How to test a callback of a mocked function in a service with jasmine?

A method of a service that I am using in my component has a callback as the second argument. When This callback is executed it returns a value which is assigned to a variable in the component. I want ...
Amit Jindal's user avatar
0 votes
1 answer
37 views

Can not seem to mock behavior subject in Angular unit test

Using Angular 16 and Jasmine/Karma. I have this subscription to a behavior subject called tableList$ ngOnInit() { const { pageNumber } = ...
dman's user avatar
  • 10.9k
1 vote
1 answer
28 views

Jasmine test Observable

I have a service class in an Angular application that I need to write tests for. The service class works well, but I am unable to write the Jasmine unit test. The service class subscribes to an ...
Amol's user avatar
  • 39
1 vote
1 answer
33 views

How to spy on nested method in service constructor in angular unit test

I have an Angular service which depends on another service, which has a property, which is an object contains a method I want to spy on. @Injectable({ providedIn: 'root' }) export class MyService {...
Ricky Mo's user avatar
  • 7,438
1 vote
1 answer
50 views

Failing the Angular tests

I am trying to run the basic angular test that angular makes when creating a component, but they keep on failing, and i cannot find why or how to fix it. These are the tests i am trying to run: it('...
Giel v Bussel's user avatar
1 vote
0 answers
46 views

Karma Test Fails with Chrome For Testing Browser

I am trying to execute the karma-jasmine test case by using Chrome For Testing browser. If I execute the test with Installed Chrome browser then the test works fine, but if same test get executed with ...
Yogesh's user avatar
  • 185
0 votes
0 answers
18 views

HTML not rendered in Karma Jasmine

It seems that the page is not rendered in my unit test. This is why I am getting the null obj when doing the assert. I am using webpack, do you know if it can be related to it ? The angular webpack ...
guiz's user avatar
  • 155
1 vote
1 answer
25 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 ...
Ricky Mo's user avatar
  • 7,438
1 vote
0 answers
63 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/...
vatsal's user avatar
  • 11
0 votes
1 answer
72 views

ng test --code-coverage-exclude not working

My use case is to generate coverage report for Angular project by excluding certain files, I've excluded those files in angular.json it's working as expected. However I'm looking to exclude them via ...
Yuvarani Kannan's user avatar
2 votes
0 answers
51 views

For each selenium request Google Chrome Browser generates 4 MB Browser Metrics file

I am using "Chrome for Testing" browser to execute my Jasmine / Selenium Test cases. While executing the test case, when browser start creating BrowserMetrics-XXXXXXXX-XXXX.pma files. Due to ...
Yogesh's user avatar
  • 185
0 votes
1 answer
57 views

How can i write jasmine unit tests for document visibility changed event

I am subscribing for the document's visibilityChanged event.Below is the code. Document is injected using dependency injection. ngOnInit(){ fromEvent(document, 'visibilitychange') ....
Niranjan's user avatar
2 votes
1 answer
642 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 **...
Nixon Darius's user avatar
0 votes
1 answer
38 views

Angular testing - subscribing to HTTP response observable triggers a new request

Context I have a service that is responsible for sending a POST request for form data to my backend. The method for sending the requests decides depending on the class instance of the form data which ...
Ynfiniti's user avatar
1 vote
1 answer
31 views

Jasmine + Karma Error: Invalid configuration of route '...' One of the following must be provided: component, redirectTo, children or loadChildren

I have this component defined inside its own routing-module file, like this: { path: '', redirectTo: 'list', pathMatch: 'full' }, { path: 'list', component: ...
gigio123's user avatar
0 votes
1 answer
71 views

Angular 17 testing mapbox

In my component I display a message after the map style was loaded: import * as mapboxgl from 'mapbox-gl'; ... this.map.on('style.load', () => { this.map.loadImage(path, (err, img) => { ...
perotom's user avatar
  • 863
1 vote
1 answer
72 views

inject() must be called from an injection context in unit test

When I am trying to use the AlertsComponent in my test file at the beginning it require some services. After adding theses services the following error appear: inject() must be called from an ...
guiz's user avatar
  • 155
1 vote
0 answers
32 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" [...
Alan Dolan's user avatar
0 votes
0 answers
578 views

Angular unit tests are failing with Error: NG0205: Injector has already been destroyed. in http://localhost:9876/_karma_webpack_/vendor.js (line 59623

We upgraded our Angular application from version 16 to 18. After upgrade our unit tests are started failing with below error. Error: NG0205: Injector has already been destroyed. in http://localhost:...
Nirbhay Singh's user avatar
2 votes
2 answers
105 views

Importing OverlayModule in Karma not working

Test file : import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { AlertsComponent } from './alerts.component'; import { ...
guiz's user avatar
  • 155
0 votes
0 answers
27 views

How to write test case for angular 15

I am trying to write test case for below the code in angular. I am new for test case.So, How to write it in the app.component.spec.ts file? I tried but not working. app.component.ts: public arr:[]= [ {...
Sansara's user avatar
  • 93
1 vote
1 answer
54 views

detectChanges() not working in Angular standalone component test with ControlValueAccessor

I have written a component test for a simple custom form control component 'my-input' (implementing the ControlValueAccessor interface) which only contains an input field. In the component test I'm ...
Stephan's user avatar
  • 43
2 votes
1 answer
93 views

detectChanges() not working in Angular standalone component test

I have written a component test for a simple component which only displays an input field for a property name. In the component test I'm setting the component's input property name to 'Stephan' and I'...
Stephan's user avatar
  • 43
0 votes
0 answers
72 views

Jasmine-Karma how to include ESM module when using Karma Test Explorer

I am using Karma Test Explorer extension for running and debugging tests in VScode. I have an angular project which is workspace project and in projects/ folder there is a "library" project ...
sander's user avatar
  • 1,626
0 votes
0 answers
39 views

Jasmine Angular unit test - Cannot read properties of undefined

I want to test the error part of the HTTP call in the myService.ts file. private executeSend(id: string): void { this.myService.createContact(id).subscribe(resp => { // some coding }, err ...
Niladri Banerjee - Uttarpara's user avatar
1 vote
0 answers
44 views

Is it possible to have more than 10 lines in the stack trace of Jasmine/Karma?

I use Jasmine/Karma for unit tests in Angular. When there's an error in a test, the maximum number of lines in the stack trace is 10 and I would to like to increase it (in order to know what test ...
Zlotz's user avatar
  • 319
0 votes
1 answer
54 views

Angular service is not making HTTP request for testing

api.service.ts import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, from, map, of, switchMap, tap, throwError } from 'rxjs'; import { ...
T090 Subhashish Nabajja's user avatar
1 vote
0 answers
17 views

Is there a way to inject or install a plugin/reporter at runtime without affecting the dev environment?

I am working on an extension for vscode and have everything working for what I want to do, except for one thing. Unfortunately, this one thing is the whole point of the extension. In essence, what I ...
Duncan McPherson's user avatar
1 vote
0 answers
18 views

How to set up Jasmine's report to print in the terminal inside an Angular project?

Is there a way to show Jasmine's report on my terminal instead of on the browser? I know that there are some npm packages to print to console, but I couldn't set up to run inside my Angular 17 project....
danilo's user avatar
  • 9,093
0 votes
0 answers
27 views

Mocking with Jasmine.createSpyObj not working as it should or my error?

So I'm testing the function grabFrame from my FrameService class and an error comes up when I mock the class dependency with Jasmine.createSpyObj: service.ts: import {Service} from "./service&...
wolfvc's user avatar
  • 101
0 votes
0 answers
115 views

Error: <spyOnProperty> : href is not declared configurable

I am new to angular test case writing. This is my .ts file import { Component, OnInit } from '@angular/core'; import { environment } from 'src/environments/environment'; @Component({ ...
Ruchi's user avatar
  • 229
1 vote
1 answer
176 views

Angular 16 route guard unit test observable createSpyObj property

Trying to familiarize with unit testing a route guard. I have a relatively straight forward guard that gets a value from a subject asObservable to either createUrlTree or return a boolean value. In ...
seguraMode's user avatar
0 votes
0 answers
68 views

Why on fresh install of Angular 17 "npm test" starts the browser 3 times, crashes when I close the window and I need Ctrl+C to stop npm command?

This is the 1st time I'm doing Angular tests and I am a bit confused of the way it works. Karma starts with chrome, but when I close the window, the browser starts again 3 times in total. Is it ...
vitasicz's user avatar
0 votes
0 answers
59 views

Wijmo upgrade failing Angular unit tests cannot read properties of undefined

I have recently upgraded grapecity wijmo from v5.20211.794 to v5.20241.9, and since then I have been facing issues with Jasmine unit tests, some tests fail with error “Cannot read properties of “...
ng_dev's user avatar
  • 155
1 vote
1 answer
63 views

Angular 16 - global import in all tests

I'm using Angular 16 with Karma/Jasmine. I want to have a module be imported by default in all my tests but am unable to find where this can be configured. I saw this post which makes use of a test.ts ...
Matt's user avatar
  • 1,570
0 votes
0 answers
74 views

Unit testing webpack bundle with Karma, is it possible?

I'm working on testing a typescript library (no Angular) where the source code is being transpiled with babel and bundled with webpack into a /dist/bundle.js file. I initialy thought that I could just ...
wolfvc's user avatar
  • 101
0 votes
1 answer
103 views

How can I mock doucment.location.href in Angular unit test

I am struggling with mocking the absolute path in Angular. it('should return current URL when no URL provided and og:url meta tag does not exist', () => { const currentUrl: string = 'https://...
Murhaf Sousli's user avatar
0 votes
1 answer
37 views

Unit testing Angular CLI - Karma/jasmine 4.3.5 jasmine component issue

For some reason I cannot make the mock data work. So it can create component NullInjectorError: R3InjectorError(DynamicTestModule)[ListingsService -> AuthService -> MessageService -> ...
Flamme97's user avatar

1
2 3 4 5
133