Questions tagged [jasmine]

Jasmine is a behavior-driven development (BDD) framework for testing JavaScript code. Jasmine has no external dependencies and does not require a DOM.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
15 views

Will Karma be updated for future versions of Angular and Jasmine?

I tried updating our companies Angular module, with that comes the required dependencies update. So I went to all the newest versions. Which included jasmine-core 5.0.0. This broke our Jasmine-karma-...
NKFahrni's user avatar
1 vote
1 answer
20 views

Best way to implement throwing error for angular jasmine component service calls?

I am trying to test this service call in angular and typescript. The typical setup for test files we utilise is to use stubs with the relevant methods on these listed but I'm wondering what the best ...
Olivia Bates's user avatar
0 votes
1 answer
15 views

I got and error: TypeError: this.todos$.pipe is not a function when create an jasmine.SpyObj as a fack service

Here is a simple todo list component: Here is my test case: fdescribe('TodoListComponent With FackService', () => { let fixture: ComponentFixture<TodolistComponent>; let component: ...
Yue Dong's user avatar
0 votes
1 answer
17 views

Problem with mongodb-memory-server buildup and teardown in Jasmine beforeEach and afterEach

I'm testing Node/Express create endpoints, and I'm using mongodb-memory-server for the in-memory database - but I'm having problems with setup. Here are my helper methods. const mongoose = require(&...
rainydaymatt's user avatar
0 votes
1 answer
18 views

Resolving template parameters of a function that's taken from the interface

I have an issue with resolving types, can't wrap my head around it. I have a ModalService with a function with such signature: openModal< T extends ModalResult = DocumentModalResult, W ...
AxirMach's user avatar
-1 votes
0 answers
10 views

Reading file contents in Jasmine/Karma tests

I have an Angular application that can process files as input, and save files as outputs. Right now in my unit tests I have to open up the files and copy the contents to a const to be able to test ...
FiniteLooper's user avatar
  • 27.4k
0 votes
1 answer
11 views

Error: sanitazer.bypassSecurityTrustStyle is not a function

I coded the follow unit test. It is quite easy but I receive continually the error: TypeError: this.sanitazer.bypassSecurityTrustStyle is not a function and I can´t figure it out. Would you mind to ...
Kenzo_Gilead's user avatar
  • 2,215
0 votes
0 answers
17 views

Testing PrimeNG Table Lazy Loading

I have created a primeNG table as follows: <p-table #dt [value]="auditTable" [lazy]="true" [customSort]="true" ...
fritz6's user avatar
  • 63
0 votes
0 answers
10 views

How to visualize karma/jasmine test failures for very large strings or objects?

I am working on an Angular project that can convert certain files to other formats. In the end I'm just generating very long strings, or very large objects and converting them into strings, and then ...
FiniteLooper's user avatar
  • 27.4k
0 votes
1 answer
17 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) { ...
Niko's user avatar
  • 562
0 votes
0 answers
19 views

How to test a non-angular form submission in an Angular app?

I have a component with a paypal button in the HTML, like this: <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type=&...
FiniteLooper's user avatar
  • 27.4k
0 votes
1 answer
17 views

Jasmine halts after 2nd call to the same async mock function in test function

I suspect Jasmine halts after running an async mocked function 2nd time in the same function, but I cant seem to find the reason or the correct workaround. The getDialogAnswer is a jquery dialog ...
DonPedro's user avatar
-1 votes
2 answers
26 views

How to get jasmine tests to ignore tabs in multiline string

I have a function that returns a multiline string like so: example line 1 example line 2 example line 3 and I'd like to be able to write like so: it('should get the proper data', () => { expect(...
FiniteLooper's user avatar
  • 27.4k
0 votes
0 answers
25 views

Angular, Jasmine: Mock constant imported from external file

Let's say there is a constant exported from file. Then there is a method in component, which uses this constant. And finally, there is a test spec which tests this method. How to simulate this ...
Frimlik's user avatar
  • 347
0 votes
0 answers
24 views

When does the async pipe subscribe during an Angular unit test with Jasmine?

I have a navbar that displays a link if you're on the login page (which directs you to the next page) and a select drop-down that displays instead once you've navigated to the next page. A minimal ...
George Foole's user avatar
0 votes
1 answer
18 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 ...
rahul mukherjee's user avatar
0 votes
0 answers
21 views

Jasmine TypeError: Cannot read properties of undefined (reading 'install')

I am on a Java maven project in the back side and the front is in Thymeleaf for a web application. I want to set up a test framework and for that I chose Jasmine. I have a problem with the tests of ...
DevRols's user avatar
  • 11
0 votes
2 answers
24 views

how to mock dynamic child component in angular

private async loadPageNotFoundContainer() { this.productErrorPageTemplate?.clear(); const { ProductErrorPageContainer } = await import( '../../lazy/product-error-page/product-error-page....
bangash's user avatar
  • 398
0 votes
1 answer
27 views

Cannot set property 'componentInstance' of undefined in unit test

I have tried different approaches (inject the component by constructor, create the mocks and spies in different ways, inject this spies to the element,...), but in the end I always end up receiving ...
Kenzo_Gilead's user avatar
  • 2,215
0 votes
1 answer
27 views

Unit test returns Cannot read property 'open' of undefined message

I am codng ia Unit Test on a code and component working. I can't understand what's going on. I have tried different approaches but I always get the same error. I have simplified the Code of the Unit ...
Kenzo_Gilead's user avatar
  • 2,215
-1 votes
0 answers
24 views

Nock and Jasmine Unit tests - Node.js environment

Just come across Nock, so first time using it. I'm looking to test the following method but my test fails with Expected spy storeDeviceId to have been called with: [ '1234-5678' ] but it was never ...
Richlewis's user avatar
  • 15k
0 votes
2 answers
43 views

Unit testing localStorage with Jasmine & JS

I'm trying to get my head around unit testing window.localStorage and I believe I'm almost there, I just can't seem to access the actual key/value pairs when testing my final helper method. I have the ...
Richlewis's user avatar
  • 15k
0 votes
1 answer
16 views

how to re-use same IT blocks in multiple spec files

in protractor, i have 20 tests (IT block) in a spec file. and we have few different spec files only the difference between each spec file is before block. Spec A Spec B Spec C so, 20 tests from Spec A ...
L V Prasad's user avatar
2 votes
0 answers
19 views

How to cover service.map in Angular Test?

I'm new to Angular UT. I find it difficult to cover this.service.map on my current test. This is the method I want to test: validateSupervisorLevel(eid = '', supervisorLevel: number): AsyncValidatorFn ...
Chukchak's user avatar
-1 votes
1 answer
49 views

How to iterate through window.localStorage

When I try to iterate over window.localStorage I don't appear to be getting any key/values I set returned. Firstly I get undefined on window.localStorage.length. I have a test setup that passes and ...
Richlewis's user avatar
  • 15k
0 votes
2 answers
28 views

Cannot figure out how the component.service is not the same than the service

I tried several approaches and I cannot find the problem. This is the furthest I've come: it('should load the current serviceData', fakeAsync( inject([Service1], (service1: Service1) => { // ...
Kenzo_Gilead's user avatar
  • 2,215
0 votes
0 answers
23 views

Jasmine tests will not complete (hang) while using Appium and WebDriverIO

I cloned the WebDriverIO Boilerplate repository, and added the capabilities and my APK. The framework correctly launches the APK on the emulator, but the jasmine wont complete the test case for up to ...
William Russell's user avatar
0 votes
0 answers
11 views

Is there a way to configure external module mocks in karma.config.js for testing in angular apps?

I have a micro frontend module i.e. utility that is getting imported in another microfrontend admin-console. Now the application runs absolutely fine... but when I run the test cases it, it gives ...
chandan kumar's user avatar
0 votes
2 answers
28 views

How do I mock a repository in jasmine to trigger the THEN in this code block?

I'm trying to increase code coverage in my project by performing simple jasmine tests on basic methods. In my controller, I have this: function fetchStates() { $repository.states().all()....
David.S.Johnson's user avatar
0 votes
2 answers
184 views

Error: Expected spy get to have been called

The following Unit Tests: const mockActiveService1 = { ....... } const mockNotActiveService1 = { ....... } describe('Component1 ', () => { let component: ...
Kenzo_Gilead's user avatar
  • 2,215
0 votes
0 answers
37 views

How to cover the line with tests

I have this code: updateAlarmWithTag(alarm: AlarmData) { this.geometricLayers.markers.forEach((marker) => { if (marker.tag === alarm.tagInfo.tag && marker.layer) { if (alarm.alarm) { ...
ojoaovitoraraujo's user avatar
0 votes
0 answers
28 views

module not found error while testing angular app with webpack externals

I have an external utility module created for using across all the angular micro-frontends. The unit test cases were running absolutely fine in the angular apps till I imported this external utility ...
chandan kumar's user avatar
0 votes
0 answers
25 views

How do you write test code for custom processing such as tabulator headerclick in Angular?

I am using Tabulator in Angular. I have added my own processing in headerClick, but I don't know how to write the test code for that. column: any[] = [ {title:"Name", field:"...
ryo ymd's user avatar
-1 votes
1 answer
39 views

mock uuid for unit test in angular

i have a case where i need to mock a uuid to run and pass the test cases, import * as uuid from "uuid" export class Test{ createData() { for (let item of raw_data) { ...
saiteja's user avatar
  • 11
1 vote
1 answer
67 views

Spy service never being called in unit test (jasmine angular)

I'm trying to understand why my test doesn't work as expected. Here is the component: @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], ...
ricardo tenorio's user avatar
0 votes
1 answer
32 views

How to test a StoreService in Angular 14 for a HTTP delete backend API service?

How to mock out a successful call to delete api service (which wraps the Angular Http service) which returns an Observable for the successful deletes scenario? It doesn't return void.
Randy's user avatar
  • 665
1 vote
1 answer
30 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: ...
WowBlueSky's user avatar
1 vote
1 answer
56 views

Unit testing a compnent that is getting data from Angular Replay Subject

I have this service called EmployeeService where I am using Angular's ReplaySubject to get data from an api. I'm subcribing to this ReplaySubject from another component which I am trying to test now. ...
s.khan's user avatar
  • 595
0 votes
1 answer
28 views

unit test the code inside valuechanges of formgroup in angular

I want to unit test the code inside a formgroup valuechanges as shown in the below. I have tried different methods like spy, fakeAsync etc. but none of them helps in achieving full code coverage. this....
dvln's user avatar
  • 111
0 votes
1 answer
32 views

Angular Testing provider useValue for environment throws NullInjectionError

I have a provider for environment in our Angular application and we have it like this: { provide: 'environment', useValue: environment } Alongside this we have a lot of other providers as services as ...
Rahul Raj's user avatar
0 votes
1 answer
30 views

Unit test angular with ngrx store and skip

I have a function which return an observable. The function implementation look like this. testFunction(): Observable<boolean> { return this.store.select(testSelector).pipe( skip(1), ...
sijo jose's user avatar
  • 197
0 votes
0 answers
23 views

Run Javascript unit tests to test user input code in the application at run time

In many code learning sites, the application is able to test the code entered by user. Ex: freecodecamp.org runs unit tests to check if user has entered correct code. I am trying to get the same ...
Smith's user avatar
  • 1,198
0 votes
0 answers
15 views

jasmine test with a token interceptor

I'm creating a unit test into my http interceptor. What it does is depending on something include a header with the token. The interceptor: private requestWithToken(req: HttpRequest<any>, next:...
cucuru's user avatar
  • 3,385
-1 votes
1 answer
14 views

Testing Angular 4 (previously Angular 2) Apps with Jasmine - Udemy Course

Someone please share the latest Angular version codes for this course, since it is written in Angular 4. My current Angular version 14 is not compatible to complete this course, so I need the ...
Theri Muthu Selvam's user avatar
0 votes
0 answers
15 views

How to test mentioned code in jasmine test cases

Component : Global variable declaration sub:any = [] ngonit() { this.sub = this.router.params.subscribe(par ams => { this.taskId = params['taskId'] } Spec.file: what I tried sofar... I tried ...
Adithya's user avatar
  • 173
2 votes
2 answers
105 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 ...
Smith's user avatar
  • 1,198
0 votes
0 answers
16 views

How can I cover a function with callback function using jasmine unit test case

I am working with Angular, Jasmine and Karma. Want to cover unit test case for the following scenario public obj: ClassA = new ClassA(); this.obj.forEachFeatureAtPixel(param, async (abc: any) => { }...
Gnik's user avatar
  • 7,018
0 votes
0 answers
17 views

VS test explorer typescript/jasmine tests in c# project not showing

I have solution with some c# libraries containg angular projects. Problem I am facing is that i cant find typescript tests from that angular projects in test explorer. In the end i can see only c# ...
Juraj Jakubov's user avatar
1 vote
1 answer
22 views

<Angular 7> Testing a function present in angular component which in turn is making a service call

I am working on writing a test case for my LoginComponent.ts in my Angular application. Inside my component there is a loginUser() method which reads the username and password from the FormGroup if ...
Shubham Arya's user avatar
0 votes
0 answers
12 views

Checking if jasmine test is called with a done callback

I'd like to replace some functions inside of test environment to make sure that they're only called inside test with done callback available. This is to catch (for example) cases where setTimeout is ...
viraptor's user avatar
  • 33.1k

1
2 3 4 5
266