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,550
questions
0
votes
1
answer
23
views
Angular Karma unit testing wait for isEmpty to emit value
I have following code for handling errors:
catchError((error) => {
return statement ? EMPTY : otherValue;
}),
I am trying to write an unit test for this....
-1
votes
0
answers
10
views
How to test "get user by name" service method using jasmine in Angular?
`it('get user by name', () => {
const testname = "Dr.R";
const testPost: doctor = {
did: 900, name: "Dr. R", age: 49, gender: "Male", specialist: "Child ...
2
votes
0
answers
20
views
Unbound breakpoint while debugging Karma tests in VS Code
I'm trying to debug Karma tests using VS Code. I managed to run tests and attach VS Code to the headless Chrome. The problem is that breakpoints don't work after attaching VS Code. But the "...
0
votes
0
answers
7
views
Angular testing with code-coverage: Unexpected token ; in JSON
I have a local less @plugin in my angular project. It works fine when running the ng serve or ng test command but fails when running the test suite with code coverage enabled.
Command ng test --code-...
0
votes
2
answers
35
views
Testing Ionic Toast button click in Jasmine
I am unable to query for one of the Toast buttons inside while testing. It simply returns null. The class is set, and that is what is being used to query.
it('should make a call to retrieval method on ...
0
votes
0
answers
12
views
Angular can't test error handling with jasmina&karma
I am trying to test my authService signIn method, with mockedAuthService. I have done scenario where, sign in passes and I also want to test the case, when it fails with backend error when credentials ...
-1
votes
0
answers
29
views
How to unit test a method in Angular service which takes a value from ngrx store ? Mocking the value from state doesnt work
I am trying to test a service which has a method which gets a value from ngrx store,on trying to unit test the method the test fails
i tried the following :
import { Injectable } from '@angular/core';
...
1
vote
0
answers
45
views
How to make test file names appear in Gitlab Junit test report?
I installed karma-junit-reporter in an angular project with the following settings:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/...
0
votes
1
answer
17
views
CKEDITOR is not defined - Karma Angular Test
we have a component in our application where we use CKEDITOR but the karma is not able to load the editor while running the ng test which error ''CKEDITOR is not definded ' at component.onInit(). I ...
0
votes
0
answers
25
views
Opa5 test cases not running in pipeline - Karma runner UI5 config
We are trying to run opa5 test case in our pipeline using Karma runner with UI5 config but it doesn't work. Here we checked all the test case and they are running fine when we run them in parts or if ...
0
votes
0
answers
27
views
Angular tests with OktaAuthModule: Having RouterTestingModule throws NullInjectorError: No provider for Router
I'm trying to run tests (Nx/Jest) with my component that uses Okta (v3).
I have a guard that extends from OktaAuthGuard with this code:
@Injectable()
export class AuthGuard extends OktaAuthGuard {}
...
0
votes
0
answers
31
views
Why do sometimes I get "not a known element" warning?
I have a service which I want to test using Karma and Jasmine.
title.service.spec
import { TestBed } from '@angular/core/testing';
import { UserPanelComponent } from '../layout/user-panel/user-panel....
0
votes
0
answers
11
views
How to excludes somes classes from code coverage for angular?
We an angular app that is tested like this:
ng test --code-coverage --watch=false --karma-config karma.conf.ci.js
With the karma.conf.ci.js:
module.exports = function (config) {
const puppeteer = ...
1
vote
0
answers
29
views
Unhandled Rejection error when running ng test
Running ng test opens a Chromium browser with localhost:9876 in a tab. Clicking on this browser immediately crashes it. The browser closes and the ng test process stops with the message ERROR [karma-...
0
votes
1
answer
46
views
Angular unit test error : Can't resolve all parameters for ExtConfig: (?, ?)
I am new to Angular unit tests. The unit test fails due to an error while running the ng test command:
Can't resolve all parameters for ExtConfig: (?, ?)
How can I fix this error?
downloadsComponent....
0
votes
0
answers
42
views
Karma fails to load test file: "Failed to fetch dynamically imported module"
I'm trying to test my LitElement components with Karma but importing PDF.JS is causing the test file not to be loaded.
Example of the LitElement component file
import * as pdfjsLib from 'pdfjs-dist/...
-2
votes
0
answers
17
views
Facing issue with angular test, this.dataservice.getpagetitle not function
i am using angular to develop a application. In this application i have created a service data service and that data service contains a method getpagetitle(). when i am calling this service and method ...
0
votes
0
answers
24
views
How to configure CHROME_BIN path in Jenkins env variable for Headless Chrome Without Puppetter
I'm working on Angular project and I'm able to run the test with karma and Jasmin on my Windows local machine with headless chrome. But Jenkins says that No binary for ChromeHeadless browser on your ...
0
votes
1
answer
28
views
Angular Excluding external javascript library from unit testing
I am unit testing my component which uses a external javascript library, I am importing and initializing the libary in my component.ts All my test cases work fine if I comment the line aksService = ...
0
votes
1
answer
42
views
sinon.spy on "import * as Module" fails after updating to Webpack 5
I am working on upgrading an application from Webpack 4 to Webpack 5. It uses babel-loader. I have production code working, but am stuck on our Karma/Sinon integration tests after upgrading to karma-...
0
votes
0
answers
19
views
Code got executed while running unit test but it shows not covered
I have a custom async validator which validate location
newStopControl:new FormControl('',[Validators.required],[this.validateLocation()]
on success validation it calls another function which ...
-1
votes
1
answer
44
views
How to unit test a function returning a Promise with then block
I have this code to initialize an authentication using OAuth2 and redirect the user to an authentication server before getting to my application
import {Component} from '@angular/core';
import {...
0
votes
1
answer
122
views
Karma Server spawn UNKNOWN -4094 Error in Angular Unit Tests
For no understandable reason, I am no longer able to run unit tests in my Angular project because the Karma Server is throwing the odd error shown below.
I am simply running npm test to trigger the ...
1
vote
1
answer
126
views
"@angular/core/testing"' has no exported member 'waitForAsync'
I am trying to import waitForAsync from '@angular/core/testing'. I am getting this error:
Module '"@angular/core/testing"' has no exported member 'waitForAsync'.ts(2305)
Any idea why?
2
votes
1
answer
97
views
Karma Disconnected reconnect failed before timeout Nightmare
I have my angular application with more than 5000 test cases.
It has been running ok before I upgraded to Angular 13 and Karma 6.3, Jasmin 3.6
After upgrade, I am getting this error while running &...
0
votes
0
answers
8
views
Angular Karma spec avoid testing child components
I am writing a spec for a component that is using a child component. From what I have read I should use "NO_ERRORS_SCHEMA" to disable loading the child component.
My HTML looks like this:
&...
0
votes
0
answers
282
views
Uncaught TypeError: Cannot read properties of undefined (reading 'X') , Angalar8 Jasmine
I have an angular@8 application, were in when I run the tests in local everything works good. but when I raise the PR and the jenkins gets triggered running the command npm ru test I am gettign this ...
0
votes
0
answers
18
views
Share mocks between different files in karma
In my tests I need to do some setup before things can be tested. This setup can be kind of slow.
Right now I'm doing the setup every test:
describe("mission", () => {
it("...
1
vote
0
answers
121
views
Unit test cases are not running after upgrading to Angular 12
Upgraded project from Angular version 5 to 12. The project is running fine but the unit test cases are not running, and just showing
Karma v 6.3.17 - connected; test: execute;
PhantomJS 2.1.1 (Windows ...
0
votes
0
answers
12
views
Migrating jest to karma : problem with @env module
Goodmorning, I hope you will be able to help me. I am migrating my test framework from jest to karma and I'm getting an error because jest import the @env module and karma doesn't. So I am wondering ...
1
vote
0
answers
64
views
Angular test jasmine, ng-mocks
I don't understand why my service is not getting called..
in my BooklistComponent, I call ngOnInit which calls initBooks() which calls the
bookApiService getAll() method...
My Setup:
beforeEach(
...
0
votes
1
answer
59
views
Angular testing with Firebase fails when testing the creation of components, but app works fine (NullInjectionError)
I am developing a chat app with angular and firebase, it is almost finished, everything seems to work fine... but the testing is giving a lot of weird errors.
For example, it says it can't create some ...
0
votes
1
answer
25
views
Expectation fails, when testing code in javascript fetch.then block
I try to verify that window.open() is called within a then block. Here is a minimal example.
import { fakeAsync, tick } from '@angular/core/testing';
function openWindow() {
const linksource = `...
0
votes
2
answers
52
views
"Server start failed on port 9876: Error: EACCES: permission denied" on 'ng test' Angular Unit Tests
Whilst running my Unit Tests in watch mode, Chrome suddenly quit and I now can no longer run 'ng test'. This randomly occurred, and has not happened in over a year of working on these tests.
The error ...
0
votes
0
answers
100
views
when testing @ngrx selectors in an @angular project unit test execution is flaky
Hello dear stackoverflow community,
we encounter flakiness when executing unit tests in our project.
we would appreciate any help or input on that issue.
Issue
do-something.effects.spec.ts and do-...
0
votes
1
answer
300
views
Karma - Chrome Headless - test FAILED - Uncaught null thrown
While running unit tests, they fail "sometimes", always on different tests, without any meaningful error.
...
Chrome 89.0.4389.114 (Linux x86_64): Executed 1225 of 1453 SUCCESS (0 secs / 3 ...
0
votes
0
answers
29
views
Karma unit tests with angular hybrid application importing modules as strings
We have an angular app that makes use of Angular and AngularJS - the project is also a mix of js and ts files. We have two karma configurations, one for the Angular tests and another for the AngularJS ...
0
votes
0
answers
129
views
I am missing code coverage when I run npm test --code-coverage
I am using an Angular 6 application. When I run the command ng test --code-coverage I get info if my tests are successful or failed but I don't get printed that in percentage like I should - so for ...
0
votes
0
answers
46
views
Disconnected (n times), because no message in using Karma-Jasmine in 60000 m
##teamcity[blockOpened name='JavaScript Unit Tests' flowId='']
21 02 2022 10:09:25.925:WARN [Chrome 98.0.4758.102 (Windows 10)]: Disconnected (0 times) , because no message in 60000 ms.
Chrome 98.0....
1
vote
1
answer
174
views
How to configure the path to test.ts in Angular CLI managed project
I've used swagger code gen with typescript-angular to generate an API client from a swagger v3 file. This is really nice, fast, and easy; however, I think the output organization is a little dated or ...
1
vote
1
answer
328
views
React Material UI Autocomplete resetting input after every keystroke in Karma+Jasmine continuous test
I have a test where I'm simulating a user typing into a Material UI Autocomplete field. When I run the test using karma start karma.conf.js --single-run everything works fine, but when the tests are ...
1
vote
1
answer
85
views
Angular Jasmine, unit test case fails when global variable assigned
I have a basic unit-test case written for two methods.
it('should populateChartDatasets call getColorCodes', () => {
component.chartConfig = mockChartConfig;
spyOn(component, '...
0
votes
1
answer
61
views
AngularJS Karma Jasmine : Expected undefined to be defined
I am new to AngularJS and working on adding unit tests in Karma and Jasmine. I have a following controller code whose method I am trying to test. I am getting the error saying that Expected undefined ...
0
votes
0
answers
17
views
¿Is there a Standard for write good tests for a complete Web App with Jasmine/Angular?
I'm learning test automation with Jasmine and Karma for my Angular web app, and I want to now if there is a Standard that define good quality tests, for example:
How many test I have to write?
With ...
0
votes
0
answers
7
views
running jest with bower components throws import errors
we have a legacy massive project written in AngularJS, with bower components, and karma jasmine for unit testing.
We want to convert to jest, but it keeps throwing bower module errors:
Is there a way ...
0
votes
1
answer
126
views
How to write a unit-test case when a boolean changes twice in jasmine-angular?
I have a basic function statement which changes boolean state of a variable when response comes in from httpClient.get observable
dataLoading:boolean;
testingFunction(){
this.dataLoading=true;
...
0
votes
0
answers
34
views
Testing a function in angular that returns on Observable<any>[] with Observables that contains error handling block
I have a function that actually pushes an Observable into an Observable<any>[]
we are actually passing an Observable<any> as an argumanet for this function which can contain other ...
1
vote
0
answers
18
views
Angular libraries testing issue in gitlab CI
I'm really exhausted of searching for this problem.
I have an Angular project ver-8 of libraries and I implemented test for these.
These are running fine on local machine but it throws error in gitlab ...
0
votes
0
answers
10
views
Karma browser issue on gitlab CI
Anyone has suggestion for this issue?
gitlab CI
2
votes
0
answers
219
views
After update to angular 13 my tests are not running
When trying to run my tests after migrating to angular 13 I get the following error. The tests were running just fine in angular 12.
START:
07 02 2022 16:10:25.729:INFO [karma-server]: Karma v6.3.15 ...