Questions tagged [karma-jasmine]
Karma-Jasmine is an adapter for the Jasmine testing framework, which is shipped with Karma by default.
karma-jasmine
6,597
questions
-2
votes
1
answer
25
views
ng test for specific module fails [closed]
Running ng test for unit tests set to a specific module fails because it includes tests from other modules.
karma version
folder structure
Image of 'test.ts' file where the test case need to be ...
1
vote
1
answer
21
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('...
1
vote
0
answers
19
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 ...
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 ...
1
vote
1
answer
20
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 ...
1
vote
0
answers
34
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/...
0
votes
1
answer
30
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 ...
1
vote
0
answers
21
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 ...
0
votes
1
answer
20
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')
....
1
vote
1
answer
117
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 **...
0
votes
1
answer
25
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 ...
1
vote
1
answer
21
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: ...
0
votes
1
answer
44
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) => {
...
1
vote
1
answer
40
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 ...
1
vote
0
answers
30
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"
[...