Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
54 views

karma don't see my test files and display this error "karma_error Uncaught TypeError: Cannot set properties of undefined (setting 'jasmineRequire')"

I'm trying to run my angular test with jasmine+karma. When i run karma start karma.conf.js it compile but i have a karma_error Uncaught TypeError: Cannot set properties of undefined (setting '...
AVA's user avatar
  • 11
0 votes
0 answers
27 views

Struggling to run Karma test in Gitpod

I am trying to run Karma tests in an Angular repo in Gitpod. When I run npm run test which leads to ng test this is the output I get ✔ Browser application bundle generation complete. 23 11 2024 08:46:...
DumbCoder7's user avatar
0 votes
1 answer
47 views

VsCode Karma DEBUG RUNNER freezes if there's a breakpoint

This problem only just started recently, and I work on a shared project so I'm not sure what might have happened that could have caused this. However when unit testing our angular project, I can run ...
Test Toon's user avatar
0 votes
0 answers
57 views

Why does Stryker JS hang when used with angular ng test?

This is my project structure: stryker.config.json: { "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json", "_comment": "This config was ...
Sara_N's user avatar
  • 33
0 votes
0 answers
128 views

Angular Karma ChromeHeadless opens blank page

I recently updated Angular (and Karma) to their latest versions, and now I get a weird blank page that shows up. For some reason, even though the blank page is there, when I click on it (or right ...
Haskell Mackowski's user avatar
0 votes
0 answers
177 views

Karma: Cannot load browser "EdgeHeadless": it is not registered! Perhaps you are missing some plugin?

I want to run karma without opening the browser, and I'm getting an error and I don't know how to make it work. Windows, Angular, Karma, Jasmine, and Edge karma.conf.js module.exports = function(...
Cinc's user avatar
  • 67
0 votes
1 answer
58 views

Karma measure each spec elapsed time

In this case I have an angular app and I noticed that some of the test specs are slower than others. I tried writing simple time reporter: function SpecTimingReporter(baseReporterDecorator, config, ...
SzymonPoltorak's user avatar
0 votes
1 answer
96 views

Spying on super class methods in Angular Unit Test with Jasmine/Karma

I am writing unit tests for an Angular component class that extends DualListComponent. The subclass, CustomDualListComponent, has a method onClickElement that calls a couple of super class methods ...
Jarvis's user avatar
  • 415
0 votes
0 answers
48 views

Run Angular unit tests using Karma/Jasmine on multi-arch Docker containers

I have some Angular unit tests developed on Jasmine and using Karma runner. I can easily run them locally on an M2 Mac but now I am developing a CI pipeline which runs the tests on arm64 and amd64 ...
Niko's user avatar
  • 790
0 votes
1 answer
40 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
6 votes
2 answers
1k views

How to disable search engine choice screen?

Using karma for unit-testing in an Angular project works fine. With a new Chrome version a "search engine selection" windows pops up on each npm run test. How to disable this ?
Reinhard's user avatar
  • 1,736
3 votes
1 answer
431 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
329 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
50 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
205 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
116 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
54 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
113 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,644
0 votes
1 answer
275 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
199 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
96 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
0 answers
36 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
100 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
163 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
50 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
1 vote
1 answer
281 views

Karma tests do not run because there is no webpack loader for .css files

I had a TypeScript project for which I recently added the first Karma tests. The browser opened during ng test showed that there were no tests, but that was not true. In Jasmine: "Incomplete: No ...
Martijn Dirkse's user avatar
0 votes
0 answers
63 views

Karma - Jasmine configuration in Aurelia 1 - disconnected after timeout

For some time, I've been banging my head with running a pretty straightforward (close to a freshly bootstrapped Aurelia project) configuration. I have a problem launching any tests, and the Chrome ...
Vladyn's user avatar
  • 583
1 vote
1 answer
87 views

Angular Mocking Service with multiple signature

In my Angular project, all the Rest services are defined like below, they have 4 signatures public commandsGet(oem: string, countryCode?: string, observe?: 'body', reportProgress?: boolean): ...
Christèle Legeard's user avatar
1 vote
2 answers
39 views

CreateSpyObject works in "beforeEach" but not in "it"

I have a component : @Component({ selector: 'app-sidenav', standalone: true, imports: [ MatSidenavModule ], templateUrl: './sidenav.component.html', styleUrl: './sidenav.component.scss'...
Burckhardt Sébastien's user avatar
2 votes
1 answer
214 views

Why does all the Jasmine related it, describe, beforeEach are marked as "Cannot find name ********"?

I have upgraded Angular app from 14 to 15, Angular Material to 15, and then MDC migration. FYI, rxjs, nodejs, typescript versions mandates have been updated too prior to upgrade. But in all the spec....
ng_dev's user avatar
  • 155
2 votes
1 answer
44 views

Angular + Jasmine - Provider not applied to inner component

I am writing unit tests for a custom table module that uses several internal components. All the internal components use ForwardRef to access input to the main table, such as the columns. The ...
Carter Smith's user avatar
2 votes
1 answer
594 views

Should we upgrade Jasmine and Karma related dependencies too during Angular upgrade?

I have upgraded Angular app recently along with Material, but somehow it resulted in more and more test fails. So, I would like to understand, whether it is a mandatory step to update the versions of ...
ng_dev's user avatar
  • 155
0 votes
0 answers
84 views

With Mathjax-angular, getting TypeError: Cannot read properties of undefined (reading 'then')

I have recently upgraded Angular app, and so updated Mathjax-angular version too just because new version is available for it. But since then when I run ng test, I am getting unit test errors like: ...
ng_dev's user avatar
  • 155
1 vote
1 answer
1k views

Karma Test Error: Disconnected, because no message in 60000 ms

I'm running "ng test" command to implement Unit Testing in an Angular project. Chrome Headless 120.0.6099.130 (Windows 10) ERROR Disconnected , because no message in 60000 ms. Chrome ...
Jekyll and Hyde's user avatar
7 votes
0 answers
3k views

How to migrate from karma to jest in Angular 17

I have recently found out about this blog post about the experimental jest support since angular 16. Based on what I understood I did the following steps: Installed the following dependencies: npm ...
ebarooni's user avatar
  • 1,898
0 votes
0 answers
185 views

Karma + Jasmine won't run any test when doing ng test or npm run test on Angular project

describe('DialogComponent', () => { it('should render DialogComponent', async () => { await render(DialogComponent) expect(screen.getByText('this should fail')).toBeInTheDocument(...
user avatar
1 vote
2 answers
540 views

Angular unit test failing setup with NullInjector error and not using Stub

I'm writing a simple standalone Logout component test using a service depending on HttpClient. I tried different solutions to just stub the HttpAuthService and every solution I tried so far all throw :...
Ben Ooms's user avatar
  • 213
1 vote
0 answers
95 views

How to complete the "ng test" process running in pipeline Jenkins

In pipeline Jenkins, I run tests of the application on Angular with the command ng test I need that after they have been executed successfully, the process completes its work, and after that the ...
alex's user avatar
  • 414
2 votes
0 answers
393 views

How to cleanly stop an "ng test" command in a terminal window

I am trying to find the best way to stop an "ng test" command when running Jasmine unit tests for my Angular project. I have looked through a lot of Angular's documentation, but there doesn'...
BlueMoose's user avatar
  • 137
0 votes
1 answer
784 views

VS Code [angular] karma test debug breakpoints only work once or twice without restarting VS code

I have been using VS code to debug my Angular jasmine karma tests for a while but I have always had a problem whereby after debugging a test several times the breakpoints stop working. I have to ...
Ben Thomson's user avatar
  • 1,123
0 votes
0 answers
52 views

Angular unit testing terminal error (Cannot read properties of null)

I'm trying to write unit tests with Angular. But I encountered the terminal error I shared in the image. I want not to get the error in the terminal and the test to be successful. Spec and component ...
Umut Akıncı's user avatar
3 votes
2 answers
1k views

Angular 16: Karma Test Explorer gives: afterAll Uncaught ReferenceError: global is not defined

Angular 16: When installing or trying to run the Karma Test Explorer in VSCode I get the following error: Failed to load tests - Test discovery failed: Browser Error - An error was thrown in afterAll ...
Brian Reinhold's user avatar
1 vote
1 answer
4k views

How to add a Karma plugin to an Angular 16 that has no karma.conf.js

I have an Angular projects which I created using the v16 CLI. All the unit tests locally fine using ng test. I now wanted to set these up to run on out build machine that runs teamcity. In previous ...
peterc's user avatar
  • 7,791
1 vote
0 answers
67 views

I have issues in unit testing angular component where ngOnInit function has to initialize async functions

this is the code inside Component.ts, ngOnInit function, I think this calls other apis (which takes time) and then initializes it: async ngOnInit(): Promise<void> { try { await this....
Kianu Yepes's user avatar
2 votes
1 answer
479 views

Ng test error, Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js)

After running ng test I received this error: ng-virtual-main.js!=!data:text/javascript;base64,...
apr_dev's user avatar
  • 123
0 votes
1 answer
41 views

IntelliJ Karma plugin: how to suppress debug output?

I'm having an Angular app and when I run unit tests using the Karma-plugin for IntelliJ I see console.debug outputs in the TestRun-tab. I want to hide those. In karma.conf.js I have stated: ...
Tobbe's user avatar
  • 138
2 votes
1 answer
4k views

Why Karma does not see any tests after updating angular to v16?

When I run ng test --source-map tests are not run. I've still got an approvement of success. Chrome 115.0.0.0 (Windows 10): Executed 0 of 0 SUCCESS (0.003 secs / 0 secs) TOTAL: 0 SUCCESS TOTAL: 0 ...
Kianni's user avatar
  • 68
2 votes
0 answers
233 views

Run Angular tests without the CLI?

Given a typical Angular CLI generated project, I'd like to run tests without the CLI (because big-business). I'd like to initiate karma using the Karma CLI. I am using Angular 16. With my setup, I'm ...
spots's user avatar
  • 2,698
1 vote
0 answers
260 views

Jenkins build stuck after running karma tests with angular version 15+

We are building our angular UI via frontend-maven-plugin , After upgrading to angular 15, the build is not moving ahead after the tests. All tests are passed and there s no skipped test. There is no ...
anurag's user avatar
  • 82
1 vote
0 answers
87 views

Loading Externals & Vendors in Webpack Files array causes tests to run multiple times

I'm upgrading from Webpack v4 to Webpack v5, and my tests are running 4 times. (only ran once in Webpack v4) Narrowed it down to this files array in the karma config: config.set({ files: [ ...
Ahmed G's user avatar
  • 41

1
2 3 4 5
93