Questions tagged jasmine

Explore the latest questions and answers asked by our top developers.

ESLint prefer-const rules is stating variable should be Const even though it IS reassigned

This is happening in one of my Jasmine Test files. ESLint states that the let variable: "files" isn’t reassigned, and so it should be a const. However literally a few lines below (128) it’s reassigned, and so if I make the fix there’s an error. I may end up making it a const, then change […]

How to exclude routing module from karma coverage?

My karma coverage is trying to cover my routing modules, and, i don’t think there’s important tests to do with that, so i’m trying to exclude this modules from karma coverage. I tried to put in angular.json: "test": { "options": { "codeCoverageExclude": ["*.module.routing.ts"] } } But my routing modules is still trying to be coverage. […]

By veroneseComS
Categorized as angular, jasmine Tagged ,

How to JUnit test HttpErrorInterceptor in angular-jasmine

I want to JUnit test my Interceptor, I developed two different way and both are passing but none of them got reach the catchError that is the part that I want really test. How can I really test that the interceptor throw the error message that I expect.Why the test is passing when is not […]

How do I test an AngularJS controllers method with multiple await – Jasmine?

I’m trying to test async method within the controller with multiple await calls but it seems like I missing something. With the setup as below, await never gets resolved, not sure why. In console, I see first log, second never. When I update method to use then instead of await it works. // Controller async […]

By Jasmin Besic
Categorized as angularjs, jasmine Tagged ,

ERROR – Calling addExpectationResult before specStarted

Could any one help me to understand why am I having this issue on running protractor e2e test within a jenkins job but none if I run it locally? Thanks in advance Source: Angular Questions

Categorized as angular, jasmine, jenkins, protractor, typescript Tagged , , , ,

Getting ‘TypeError: Cannot read property ‘ngModule’ of undefined’ when creating a unit test in angular

I am currently doing unit tests in a bigger project and for some reason I am getting the mentioned error when running my test. This is my code: it(‘first test, () => { expect(‘test’).toBe(‘test’); } But this fails. I imported the CommonModule and the component modules used. But even this simple test fails. Does anyone […]

By IonicMan
Categorized as angular, jasmine, jestjs, unit-testing Tagged , , ,

My spy is being called but my function is not being covered in karma coverage

I have a sidenav component and inside i have a header component: <div> <app-header id="header" (openSidenavEmitter)="openSidenav()"></app-header> </div> My header component have a event emitter that when the user click in the hamburg icon, it emits a event to parent component to open the sidenav: @Output() openSidenavEmitter = new EventEmitter(); openSidenav() { this.openSidenavEmitter.emit() } In my […]

By veroneseComS
Categorized as angular, jasmine Tagged ,

How to do a test with an array of routes in angular?

I’m trying to do a test that calls by route, but it doesn’t work. on my TS has this array of routes in the menu: menu(): Array<MenuItem> { return [ { label: ‘Home’, shortLabel: ‘Home’, action: () => this.router.navigate([‘home’]), }, { label: ‘Request’, shortLabel: ‘Requests’, action: () => this.router.navigate([‘request’]), }, { label: ‘About’, shortLabel: ‘About’, […]

Angular service test – Uncaught TypeError: response.forEach is not a function thrown

When I send a request in my example.service.ts everything works fine and I can iterate the response as shown below. example.service.ts: this.returnExampleData().subscribe((response: any) => { response.forEach(element => { console.log(element) }) }); However when I run the same method in my service test I get the error Uncaught TypeError: response.forEach is not a function thrown. Any […]

NgRx effect unit tests get Jasmine spy call counts mixed up

I have an NgRx effects where I want to unit test a success and also a fail scenario. In the fail, I originally had an issue where if the catch was executed, it would kill the effect observable (same problem as explained, with solution here I am using version 12.2.0 of NgRx. So, in the […]

By peterc
Categorized as angular, jasmine, ngrx Tagged , ,
1 2 3 88

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us