Questions tagged [angular2-testing]
289 questions
1
vote
1 answer
Extending method with generic obeservable as return type
rxjs: 5.0.0-beta.2
Typescript: 1.8
Angular2: beta-9
I'm trying to mock a http service class but run into problems when extending the class as described in angular 2 docs.
Seems like you can't override a method that returns an typed observable? What…

Darkness
- 49
- 4
1
vote
2 answers
How to make karma work with a webpack, Angular2, and SASS project?
I am using angular2-webpack-starter and I have my stylesheets as SASS. Everything is working perfectly, but when I try to run karma tests it fails giving me this error
ERROR in ./src/app/widgets/message/messages.scss
Module parse failed:…

Mostafa Fateen
- 849
- 1
- 14
- 33
1
vote
1 answer
Angular 2 rc.1 testing with ES5
Using ES5 with Angular 2 RC.1 modules the npm packages provide the *.umd.js required to run an Angular 2…

Ryan
- 832
- 2
- 8
- 14
1
vote
1 answer
Testing routerLink directive in Angular 2
I'm trying to test the work of routing. I moved navbar to a separate component - MdNavbar. Basically only html and css in there, the RouteConfig is in other component and MdNavbar is injected in there. I want to test that route changes when clicking…

renchan
- 519
- 5
- 24
0
votes
2 answers
Ionic Storage v3 - Unit Tests | TypeError: _this.storage.forEach is not a function
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-angular';
@Injectable({
providedIn:…

Dana
- 151
- 1
- 7
0
votes
1 answer
Angular 9 : Karma Coverage : How to display coverage report with only specific files
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 *.ts files in the report.
However, I just need…

Curious Explorer
- 357
- 2
- 14
0
votes
0 answers
How to Handle zone-evergreen.js HTTP 400 Bad Requests in Protractor?
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 error "Email already exists". (and this is the…

edrakali
- 155
- 1
- 5
0
votes
2 answers
Angular e2e test with Protractor: click intercepted by parent of element selected by id
Sometimes I get this error but not every time I run the test. What is causing this strange behavior?
Failed: element click intercepted: Element
...
is not clickable at point (616, 104). Other element would receive the…
Francesco
- 405
- 3
- 15
0
votes
1 answer
How to test if statement in ngOnInit that depends on route param
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 sets cached to be true so it goes into the if…

Anonguy123
- 407
- 3
- 16
0
votes
1 answer
Unit test fails after adding a new test
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 fine individually (if started with fdescribe, or if I…

Andreas Gassmann
- 6,334
- 7
- 32
- 45
0
votes
0 answers
Angular4 Karma-Jasmine test not running
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 tried to change the 'target' and 'module' amongst…

Ram
- 527
- 1
- 10
- 26
0
votes
1 answer
Unable to locate the function in spec file
Example.ts
export class Example{
public async initService(Id): Promise {
//promise logic
}
}
Example.spec.ts
//imported Example class correctly
describe('testing', async () =>{
it('InitService test call', async ()=>{
…

Aditya
- 2,358
- 6
- 35
- 61
0
votes
1 answer
How can you create a new (xml) file in angular testing
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(['ANEWFILE001'], {
type: 'application/xml',
endings:…

Babulaas
- 761
- 3
- 13
- 47
0
votes
0 answers
How to share TestBed between specs of sibling components in Angular?
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 way.
For example, if I have:
parent.module.ts --->…

ashish.gd
- 1,713
- 1
- 14
- 25
0
votes
0 answers
Angular2: Unit testing a component with Route resolve
I have a component that depends on a data from Route Resolve.
Following is the code snippet of the router
{
path: 'attachment',
component: SgCreateAttachmentComponent,
resolve: {
…

SNP
- 78
- 2
- 10