Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
257 views

I have a StorageService wrapper for @ionic/storage-angular where I have a function that looks roughly like this: import { Injectable } from '@angular/core'; import { Storage } from '@ionic/storage-...
Dana's user avatar
  • 161
2 votes
2 answers
804 views

I'm using Angular 14. I'm trying to test this service: import { EnvironmentService } from './environment.service'; import { MsalService, MsalBroadcastService, MSAL_GUARD_CONFIG, MsalGuardConfiguration ...
SteDeus's user avatar
  • 57
5 votes
2 answers
3k views

Angular can Query subComponents by Types, which is used in Testing like this: fixture.debugElement.query( By.directive( ComponentType ) ); Now i wanted to make a function which does this for me: ...
Jeremias Nater's user avatar
0 votes
1 answer
4k views

Background We have an existing a huge angular application without any unit tests and we have just started writing the test cases. When I run the command ng test --code-coverage Problem I see all the *...
Curious Explorer's user avatar
0 votes
0 answers
770 views

I am writing a test with Angular11/Protractor which fills a registration form and then submits it to the backend server. The test expects that the server will respond with an HTTP 400 Bad Request ...
edrakali's user avatar
  • 175
1 vote
0 answers
1k views

I am using Angular CLI: 10.2.3 Node: 12.22.1 npm: 6.14.12 I am new to angular. I am trying to use jest for testing angular code (project runs fine without any errors, now adding some tests where I see ...
Mihir's user avatar
  • 603
2 votes
1 answer
7k views

Failed: Cannot read property 'queryParams' of null at I'm assuming it's because I have the following in ngOnInit(): ngOnInit() { this.route.queryParams.subscribe(async params => { this....
D.Hodges's user avatar
  • 2,119
1 vote
2 answers
549 views

I'm trying to do a bare minimum test on my Angular 4 components, and I can't get it to work at all. I'm running this command: karma start src/test/javascript/karma.conf.js And here is the output: ...
Mike K.'s user avatar
  • 626
1 vote
1 answer
2k views

I am writing a unit tests for Angular 2 component with Jasmine. I will like to test if my document metatags as been set to a specific value when my component is instantiated. My component: import { ...
Alex Slav's user avatar
  • 195
0 votes
2 answers
730 views

Sometimes I get this error but not every time I run the test. What is causing this strange behavior? Failed: element click intercepted: Element <div id="myButton">...</div> is not ...
Francesco's user avatar
  • 435
1 vote
1 answer
888 views

I am writing Karma tests for my angular application. I use custom form controlls that are created with the ControllValueAccessor. Is there a way to test the implemented ControllValueAccessor methods (...
Nealv's user avatar
  • 6,884
0 votes
1 answer
3k views

My Angular 8 web app has one component that does different things depending on the route. In ngOnInit I use route data to check if the cached param is present. I am trying to write a unit test that ...
Anonguy123's user avatar
4 votes
1 answer
1k views

My aim is to unit test NewServicesRequestsComponent , I was able to resolve other dependencies but stuck with the service dependency named GenericService I tried out resolving XHRbackend error by ...
Enthu's user avatar
  • 532
3 votes
1 answer
1k views

I'm new to Angular and attempting to test an Angular 6 service which utilizes handlebars.js to build client-side html templates, based on input JSON / data. The service produces the desired result in ...
Andrew's user avatar
  • 1,526
1 vote
1 answer
506 views

The testbed config is TestBed.configureTestingModule({ declarations: [ EditPersorgaComponent, ArrayFromIntPipe, TeamFilterPipe ], schemas: [ NO_ERRORS_SCHEMA ], ...
Ramakanth Reddy's user avatar
0 votes
1 answer
367 views

I am currently working on an Ionic (v3) app and we have several tests to test services, pages and components. Everything was working fine until I added a new test for a component. Both tests run ...
Andreas Gassmann's user avatar
1 vote
3 answers
714 views

How do I list all the dependency injectors of a component in angular? This requirement is for unit testing. I have an instance of a component created as follows : component = fixture....
Amit Chigadani's user avatar
6 votes
2 answers
7k views

I have a components that gets a value from the params property of a ActivatedRoute. The components looks like: ...... constructor(public userRegistration: UserRegistrationService, public userLogin:...
AleGallagher's user avatar
  • 2,033
2 votes
1 answer
5k views

How to make change detection in unit tests work properly? From sources, changeDetection should be ran after microtasks are empty (including event tasks?). this._onMicrotaskEmptySubscription = ngZone....
Ilia Volk's user avatar
  • 556
2 votes
1 answer
4k views

We writing test case for a component which has many nested services and components (we cannot mock every service for our requirement). We have created module which contains all the components and ...
Sudheer KB's user avatar
  • 1,606
9 votes
1 answer
9k views

I writing unit test for angular 2 by jasmine + karma. I have the component check exception and throw error. And write unit test to check this case. But I seen an error message when trigger fixture....
ThuyNguyen's user avatar
  • 1,185
1 vote
0 answers
155 views

I'm using SystemJsModuleLoader to load modules, it works just fine. But when I test my app, whenStable didn't works as it describes. It resolves so fast that systemjsLoader.load() hasn't resolved yet. ...
Elliot  Xu's user avatar
1 vote
2 answers
5k views

I have this simple method which needs to be tested: public onLayerContainerClick(event: Event): void { event.stopPropagation(); event.preventDefault(); if (event.srcElement.classList....
pop's user avatar
  • 3,792
6 votes
2 answers
3k views

I am using karma viewport npm package to set the viewport for chrome browser via jasmine test spec. I am following the guidelines from the link provided above. It's quite simple, but somehow I am not ...
Amit Chigadani's user avatar
47 votes
3 answers
21k views

I have a pipe that sanatises HTML as below: import { Pipe, PipeTransform } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; @Pipe({ name: 'sanitiseHtml' }) export ...
Ben Taliadoros's user avatar
3 votes
2 answers
1k views

For some reason Location.normalize() and other functions doesn't return correct response when I run tests: import { Router } from '@angular/router'; import { Location } from "@angular/common"; import ...
Yuri G.'s user avatar
  • 33
6 votes
0 answers
8k views

I am trying to test the HTTP calls and referring to the following page to write unit tests: https://angular-2-training-book.rangle.io/handout/testing/services/mockbackend.html But when I looked on ...
Abhishek Sharma's user avatar
2 votes
1 answer
1k views

Is there a way in jasmine where I can combine toHaveBeenCalledTimes with toBeGreaterThan? I want to know whether the spy object has called a particular method at least 2 times. spy Object spyOn(...
Amit Chigadani's user avatar
2 votes
1 answer
1k views

I have a save method. public saveJob(formData: any, redirect: boolean = false): Observable<any> { if (!this.checkJobValidity()) { return Observable.of(null); } return this....
Josf's user avatar
  • 795
0 votes
0 answers
661 views

I am trying to get my Karma-Jasmine tests set-up and can't work-out where I am going wrong. Can't seem to understand where the problem is and have tried various solutions from online searches have ...
Ram's user avatar
  • 563
5 votes
2 answers
7k views

I have a unit test as below it('billing information is correct', () => { fixture.detectChanges(); spyOn(component.myEventEmitter, 'emit').and.callThrough(); component.form.controls['...
Josf's user avatar
  • 795
1 vote
1 answer
2k views

Context My issue is that my ngOnInit function calls many sub functions asynchronously by using Firestore to populate a form from one document as well as subscribing to various collections to display ...
Matthew Mullin's user avatar
6 votes
1 answer
3k views

I have a component which employs template-driven form <form (ngSubmit)="onSearchCorpus(form)" #form="ngForm"> <combo-box [(ngModel)]="model.corpus" name="corpus" #corpus="ngModel"></...
dKab's user avatar
  • 2,868
4 votes
2 answers
2k views

I am trying to write a test to ensure that my method returns the right value based on one of the component's properties. So in my unit test I want to set the value of the component's properties and ...
Chris Lang's user avatar
2 votes
0 answers
2k views

while writing jasmine unit test case for one of my angular 2 component, if I add CookieService in provider list then all remaining other component unit test cases are failing. If I remove ...
Srikanth Pallerla's user avatar
0 votes
1 answer
949 views

Example.ts export class Example{ public async initService(Id): Promise<any> { //promise logic } } Example.spec.ts //imported Example class correctly describe('testing', async () =&...
Aditya's user avatar
  • 2,556
0 votes
1 answer
1k views

I am working on an unittest in a Angular(2) project. But I ran into an issue that I can not create a new File for my test. In my test I have the following code: const newfile = new Blob(['...
Babulaas's user avatar
  • 899
8 votes
3 answers
5k views

I am new to Protractor. I have developed few tests cases to accomplish the end to end testing. These test cases works fine in all 3 different environments that we have : dev, testing and production. ...
Sameer K's user avatar
  • 799
1 vote
0 answers
612 views

I've got a problem - when I try to configure testbed, it throws error Failed: Uncaught (in promise): Failed to load /student-register.component.html I tried to solve this problem by overriding the ...
Jędrek Markowski's user avatar
0 votes
0 answers
1k views

I am looking for a way to share the TestBed between different files in Angular spec files. I understand, that I can always write a simple util class to do so, but am not sure if that is the correct ...
ashish.gd's user avatar
  • 1,778
0 votes
0 answers
1k views

I have a component that depends on a data from Route Resolve. Following is the code snippet of the router { path: 'attachment', component: ...
SNP's user avatar
  • 78
2 votes
1 answer
273 views

I have an Ionic2 project, with the Unit Testing setup based on the clicker repository. I try to use a Floating Action Button in a component but it throws an exception when running the unit tests. I ...
Robert's user avatar
  • 23
3 votes
1 answer
1k views

I have been learning Angular 2 unit testing for the last month or so and have come across a tedious process that I am trying to figure out how to get around. This tedious process has to do with ...
Shamrocck's user avatar
5 votes
1 answer
3k views

I've got a custom from control with selector app-date-picker. It implements ControlValueAccessor. I have a component called MyPage that contains this custom form control via: <app-date-picker ...
Andrew M.'s user avatar
  • 852
2 votes
1 answer
933 views

I am able to navigate to the page, but on the navigated page I am trying to click the button which is showing error as follows: × navigates to the next page on click - Failed: unknown error: Element &...
Aditya's user avatar
  • 2,556
0 votes
1 answer
877 views

I have started using the protractor with jasmine on an ionic2 application.I have 2 major doubts that did not gets cleared on searching on web: 1.)When any of my specs fails the tests, the error is ...
Aditya's user avatar
  • 2,556
0 votes
1 answer
803 views

Part of my service.spec.ts is below: service.spec.ts it('should mock the http requests', inject([Service, MockBackend], (service, mockBackend) => { let result:any; mockBackend.connections....
Aditya's user avatar
  • 2,556
0 votes
0 answers
2k views

Technologies Used: Karma/Jasmine, Angular2 service.ts Injectable() export class Service { constructor(private http: Http) { } getGoogle(): Observable<any>{ console.log("...
Aditya's user avatar
  • 2,556
1 vote
1 answer
9k views

I want to test one of methods which helps in closing Modal Window when closed outside of Modal Window container. Component Method public hide(): void { this.visibleAnimate = false; ...
Gags's user avatar
  • 3,831
0 votes
1 answer
30 views

The function I want to test is asynchronous, This function is present in a class. Do I need to create a mock/stub to test this function?If yes then how to create one? delayedAlert(message: string, ...
Aditya's user avatar
  • 2,556

1
2 3 4 5 6