Skip to main content

Questions tagged [karma-runner]

Karma provides developers a testing environment where they don't have to set up many things, rather just write code and get instant feedback in order to improve productivity and creativity.

0 votes
0 answers
24 views

Tests coverage generation is randomly failing

I am trying to generate a coverage report for my Angular tests using Karma. I implemented a pipeline that simply runs ng test --watch=false --code-coverage=true Every now and then, using the same VM, ...
Rafael Lima's user avatar
0 votes
0 answers
10 views

How to use relative paths in SCSS URLs which work for Angular application and karma builds

I've migrated a project to Angular 18 using @angular-devkit/build-angular:application as builder. During the migration process all relative paths in SCSS image URLs have been changed from "~/src/...
Ulrich Wengert's user avatar
0 votes
1 answer
27 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 ...
user2280852's user avatar
0 votes
0 answers
11 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
39 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
2 votes
2 answers
99 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
29 views

Error: Expected one matching request for criteria "Match method: PUT, URL: http://localhost:3000/api/v1/users/1", found none

I am trying to create unit tests for a full-stack application I am writing to practice learning angular. I am trying to create mock requests to test the functions of my frontend without actually ...
aqex's user avatar
  • 1
0 votes
0 answers
31 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,616
0 votes
2 answers
65 views

Jasmine/Karma error "TypeError: Cannot read properties of undefined (reading 'events')" error after putting routerLink on Angular template

I am trying to make some tests in my Angular app, but when I add this line with routerLink, the tests gives me errors: <a class="nav-link" routerLink="../loja-lista" role="...
Mauro Gabriel's user avatar
0 votes
0 answers
100 views

Testing HttpInterceptorFn with rxjs retry operator

I'm trying to do some unit tests for my retry policy with the new interceptor function that Angular 17 provides. Here is the interceptor code: import { HttpErrorResponse, HttpInterceptorFn, ...
Jase's user avatar
  • 91
0 votes
0 answers
54 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
  • 91
0 votes
0 answers
31 views

Angular Testing Error when there is Class[].push

let's say I have firstComponent that already have success ng test. in the test Im doing some test related to router and have this line const mockRouter = jasmine.createSpyObj("Router", [&...
Yohanes Aditya's user avatar
1 vote
1 answer
72 views

Angular 15 unit test - Cannot read properties of readonly constant, why?

I can't run unit tests with Angular 15.2.10 and Karma 6.3.12, I have also tried Karma 6.4.3 but has the same problem. The odd thing is that it gives me error in a readonly constant not in a variable. ...
mistermaster's user avatar
1 vote
0 answers
53 views

Are test.ts and test-acceptance.ts not required from Angularv15 onwards?

I have upgraded to Angular15 recently, but unit tests weren't running, after some exploring, I got to know that main:"test.ts" needs to be removed from angular.json's test block, and instead ...
ng_dev's user avatar
  • 155
0 votes
0 answers
30 views

Karma with external stencil webcomponents

How can I run an external Stencil web component in Angular under Karma so that I can access the shadow DOM and the component is rendered in the Karma runner? Edit: With setTimeout on 300 and a normal ...
Steffen Kämmerer's user avatar

15 30 50 per page
1
2 3 4 5
309