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.
4,611
questions
0
votes
0
answers
26
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,...
0
votes
0
answers
21
views
Uncaught TypeError: __webpack_require__(...).context is not a function - Karma Jasmine Error in Angular V16
When I try to run tests in Angular V16, I get the following error.
An error was thrown in afterAll Uncaught TypeError:
webpack_require(...).context is not a function TypeError: webpack_require(......
0
votes
0
answers
16
views
Timezone is not set on a dayjs object when created
I have a Karma test in a web application. In the test, I had created a dayjs date. Sometimes when I create the dayjs object, the time zone is not set. This problem occurs when I run all test in the ...
0
votes
0
answers
15
views
Karma testing using selenium docker containers
I've been tasked with fixing a CI pipeline at work. Additionally, the pipeline should be switched to docker and use selenium browser containers (for example selenium/standalone-edge). I hit a ...
0
votes
0
answers
18
views
Is there a way to parse karma test runner report to find test failures?
I tried various libraries like
karma-verbose-reporter
karma-failed-reporter
karma-spec-reporter
and all of them failed to report the number of failures. The best message I've got is this so far
[...
0
votes
0
answers
9
views
Karma dosen't generate lcov.info
When I run ng test --watch=false --code-coverage I don't receive an lcov.info file...
Anyone could have an idea? a feedback or experience about this issue please ?
my karma.conf.js
module.exports = ...
0
votes
1
answer
11
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:
...
0
votes
1
answer
128
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 ...
1
vote
0
answers
31
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 ...
1
vote
0
answers
96
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 ...
1
vote
0
answers
44
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: [
...
0
votes
0
answers
18
views
Karma config proxy configuration gives 'failed to proxy' error
I have my project folder like so:
-src
-resources
resource1.txt
resource2.txt
// and more
-unittests
assets
assetList1.txt
assetList2.txt
// and more
karma.conf.js
...
0
votes
0
answers
77
views
<spyOnProperty> : isInCreateMode is not declared configurable
I have an Angular 15 application and I'm using Karma for Unit testing along with Mobx as the StateStore.
I'm mocking the following mobx code in Karma/Jasmine:
@computed get isInCreateMode(): boolean {
...
2
votes
2
answers
196
views
Getting 404 when running Karma Jasmine tests with code coverage
When running ng test --browsers ChromeHeadless --code-coverage on my Angular project, it aborts with a 404: /_karma_webpack_/main.js error and shows "Unknown values" under the coverage ...
0
votes
0
answers
41
views
With destroyAfterEach defaulting to true in Angular 13+, is there any need to clean up in an afterEach?
I often see test suites that include something like
afterEach() {
fixture.destroy()
// or TestBed.resetTestingModule();
}
Meanwhile, in Angular 13 and later, ModuleTeardownOptions....
0
votes
0
answers
48
views
I need to upgrade Karma and Jasmine versions
I need to upgrade Karma and Jasmine versions but I don't know if I have to update all of these packages or not:
"jasmine-core": "2.8.0",
"jasmine-marbles": "0.8.3&...
0
votes
0
answers
18
views
Error when unit testing Angular service decorated with Injectable
I have an angular service, very simple inside. I wrote couple of unit tests and my Jasmine/Karma runner throws errors lile:
Uncaught TypError: (0, tslib_WEBPACK_IMPORTED_MODULE_0__.__decorate) is not ...
1
vote
1
answer
281
views
Karma hangs for 30 seconds after successfully executing unit tests
After the successful execution of all unit tests, Karma hangs for 30 seconds and then outputs the following message:
Chrome Headless 114.0.5735.35 (Windows 10) ERROR
Disconnected , because no ...
0
votes
0
answers
36
views
How to write Angular unit test for a nested Form
In my angular app, I have a html which has nested form.
The data passes through MainForm to its childs.
I have a method populateForm() in MainForm.component.ts which populates values in all the forms.
...
0
votes
0
answers
20
views
Why is my karma tests runs without angular application?
I've downloaded angular+karma+jasmine project from the internet, and when i run "ng test" it looks like this
But when i create my own project in angular, and write "ng test" it ...
-1
votes
1
answer
25
views
Difference b/w running test cases in angular frameworks vs the compiler default?
Diff b/w running angular testing in jasmine / karma etc vs doing it in the ng serve when the project gets saved & compiled automatically. Why is there a need for the testing Framework in angular ...
0
votes
0
answers
13
views
Why is my karma test runs without angular application?
(https://i.stack.imgur.com/w00Jw.png)
So i'm testing angular app with selenium, jasmine, karma. But things don't go well.
When i run it by "ng serve" - app works fine
But on "ng test&...
0
votes
0
answers
63
views
Angular Harness - TypeError: Cannot read properties of undefined (reading 'locatorForOptional')
I am writing tests in Angular, Karma with Harness but i do not have material in my app.
My HTML:
<ng-container *ngIf="headerOK">
<table-filter
*ngIf="...
0
votes
0
answers
167
views
HeadlessChrome GitLab CI
The excat error code I recieve from GitLab looks like this:
$ npm run test -- --no-watch --browsers=ChromeHeadlessCI
> [email protected] test
> ng test --no-watch --browsers=ChromeHeadlessCI
- ...
0
votes
0
answers
24
views
Writing Angular Unit test for Nested rest Get Calls
I am writing a funtion in Angular which is inheriting getSingle suntion of some other Service file, two times, when i am writing the Unit test , it says, getSingle already spied upon. Please help me ...
0
votes
1
answer
129
views
Karma+Jasmine: Mock external library defined on window object
I am developing a Javascript SDK and I am using an external library defined on the window object
private getFromATS(): string {
return window.ats.retrieveEnvelope(function (envelope: string) {
...
0
votes
0
answers
34
views
Pantomjs not starting while running ng test in DockerFile
`17:09:57 12 05 2023 11:39:57.559:INFO [karma]: Karma v1.7.1 server started at http://localhost:9876/
17:09:57 12 05 2023 11:39:57.560:INFO [launcher]: Launching browser PhantomJS with unlimited ...
0
votes
1
answer
26
views
How to write test case for if else with htmlelement in karma jasmine test case?
**Component code:**
@HostListener('document:click', ['$event', '$event.target'])
onClick(event: MouseEvent, targetElement: HTMLElement): void| boolean {
try {
this.shareService.addBreadCrumb('Host ...
0
votes
1
answer
56
views
How to use karma in node and return a Promise from Server.start when singleRun is true
I'm trying to use node to create a tool that will run Jasmine via karma several times based on configuration info I send it.
I'm starting with calling karma once and I'm having trouble with the server ...
0
votes
0
answers
162
views
Karma keeps disconnecting with error -- TypeError: Cannot read properties of null (reading 'xxxx')
Karma keeps failing and disconnecting with the following error
26 04 2023 08:10:56.565:ERROR [karma-server]: TypeError: Cannot set properties of null (setting 'manual-3315')
at ...
0
votes
0
answers
73
views
Error Zone is not defined when doing Karma test
I am trying to test a service in Angular and it keeps throwing this error:
An error was thrown in afterAll
Uncaught ReferenceError: Zone is not defined
ReferenceError: Zone is not defined
I have ...
0
votes
0
answers
28
views
Karma.js is taking more than 30 seconds to create test after hitting the run command
On hitting the command - node_modules.bin\karma start js\tests\karma.conf.js the test takes more than 30 seconds to start.
I have checked the automation logs for any clue but apparently no logs are ...
1
vote
1
answer
67
views
Angular - Mock new Audio() with Jasmine
I have an angular service that plays a sound on a certain condition. I would like to mock the window's Audio class to spy on the play function to check if it's actually called.
Here is my class:
...
1
vote
1
answer
177
views
How to test a Angular pipe with own dependencies (injected with NG 15 inject())?
A minimum working example, in a fresh Angular 15 CLI app:
A (blank) service HelperService
This service gets injected into DemoPipe with the new inject() call:
export class DemoPipe implements ...
2
votes
2
answers
210
views
Run tests in browser in angular app in run time
I am building a angular app where i want to take user JavaScript code input(ex a function), run the unit test to verify if the input code is proper and display to user if test has passed or failed. I ...
0
votes
0
answers
35
views
Webpack/karma always reports 50% branch usage for all files
I am trying to add code coverage to my web project and found that, no matter what I do, my coverage for all files is always 100% for statements, functions, lines, but branches are always 50% (it lies)....
0
votes
0
answers
15
views
No class def found error unable to resolve this
enter image description hereNo classDefError
added few dependency also but not working
0
votes
0
answers
148
views
Webpack UnhandledSchemeError error when using filenamify lib
On an Angular 15 application, I have added the filenamify dependency, and used it as follows:
import { default as filenamify } from 'filenamify';
...
const result = filenamify("hello there !.-?&...
0
votes
0
answers
56
views
Tests not running with Karma/Mocha/RequireJS - "Mocha instance is currently running tests, cannot start a next test run until this one is done"
I'm trying to use Karma and Mocha to run tests with RequireJS. When running karma start karma.conf.js, the CLI outputs Executed 0 of 0 SUCCESS (i.e. the test case is not being detected).
On the ...
0
votes
0
answers
139
views
Jasmin test cases fail on Angular 14
Not able to execute unit test with karma framework on angular project.
{
"dependencies": {
"@angular-material-components/datetime-picker": "^7.0.1",
"@...
1
vote
1
answer
30
views
state of service can't be mutated in the component's unit test jasmine
I have a component that consumes a resource from a service.
export class BarService {
age: string = '';
private dare$ = new BehaviorSubject<boolean>(false);
delete() {
throw new Error('Delete')...
1
vote
0
answers
228
views
Angular Unit Test with puppeteer opens a command line window, breaks debugger
On an Angular project we use Puppeteer to include a Headless Chrome binary on dependency installation, it helps on a lot of things, including CI. The way to do this is described Here
It always worked ...
0
votes
0
answers
56
views
Spec file not able to create component successfully for Unit testing using Jasmine Karma
Default spec file in Angular framework is not able to create component for Unit testing using Jasmine Karma because of following error
Chrome 111.0.0.0 (Mac OS 10.15.7) VaccineCheckerComponent ...
0
votes
1
answer
96
views
Running Angular test from IntelliJ (karma) adds invisible breakpoints before each test?
I was used to debug test in my Angular project directly from Intellij.
Running them directly with the small green arrow using 'run' works fine. But when I switch to 'debug' it stops before each test (...
0
votes
0
answers
312
views
Angular 15 - Karma : Error: Automatic publicPath is not supported in this browser
I updated my app to angular 15 (15.2.0) but I got an error when I run karma test with npm run test :
The error is caused by Error: Automatic publicPath is not supported in this browser. It only ...
1
vote
1
answer
2k
views
Unable to generate karma.conf in Angular
I am practicing CI/CD and started to configure karma.conf. However, I found that Angular projects no longer have karma.conf, and the official recommendation "ng generate config karma" doesn'...
0
votes
1
answer
184
views
Unit Test Angular ----> Error: Cannot make XHRs from within a fake async test
I'm having trouble creating the unit test for my "homepage" component.
I want to test the function loadNews().
This is the error: Error: Cannot make XHRs from within a fake async test. ...
0
votes
0
answers
93
views
ChromeHeadless failed 2 times (timeout). Giving up
karma.config.js
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
...
0
votes
0
answers
28
views
Test angular reactiveForm with multiple mat-select controls in a angular environment?
I have angular reactive form with multiple mat-select values already auto-populated before the form loads. Basically its a filled form.
<pre><code>
it('TEST FORM GROUP', () => {
...
1
vote
1
answer
273
views
Karma-Jasmine do not identify all Angular unit tests when using Automerge package
Problem:
Having a weird issue with the Karma runner. It does not identify all the unit tests while running ng test command.
Reproduce:
I have created this stackblitz: https://stackblitz.com/edit/node-...