Questions tagged [angular2-testing]

289 questions
0
votes
1 answer

How can I remove the npm error from the protractor's logs when any spec fails?

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 displayed with npm errors, shown in the below: 1)…
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
1 answer

The value of the JSON array displays undefiend after converting it into string

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.subscribe((connection) => { …
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
0 answers

Expected undefined to equal 2

Technologies Used: Karma/Jasmine, Angular2 service.ts Injectable() export class Service { constructor(private http: Http) { } getGoogle(): Observable{ console.log("Inside service"); return…
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
1 answer

Do I need to create a mock/stub to test this asynchronous function?

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, time: number, cb){ return…
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
1 answer

How to test an asynchronous function using karma/Jasmine in ionic2?

Below I have written down the code in which there is an asynchronous function, that uses setTimeout() internally and prints message after 3seconds. I have to write the spec using Jasmine. I have followed the docs but I didn't get how to apply this…
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
1 answer

How to actually trigger a click event and check the outcome in Angular2

I want to actually check, that the selected attribute has been rendered with a true instead of an undefined. My working (manually tested) Component functionality: export class PlayerSelectorComponent implements OnInit { players: any = [] …
Igor L.
  • 3,159
  • 7
  • 40
  • 61
0
votes
0 answers

Protractor +Cucumber Error: CompositeParserException: Parser errors in angular 2

I get this error **CompositeParserException: Parser errors : (2:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given I am on the "home"'** when I run protractor conf.js. I am referring this…
user2301
  • 1,857
  • 6
  • 32
  • 63
0
votes
1 answer

How to run tests written using jasmine for typescript (angular 2)?

I have written unit tests using jasmine framework for angular 2 typescript application. I have not generated project using angular-cli. I installed jasmine and wrote the unit testing for angular component. How do I run this spec.ts ? I followed this…
user2301
  • 1,857
  • 6
  • 32
  • 63
0
votes
0 answers

How to write and run unit test cases for angular 2 typescript without using any external framework?

I tried to write unit test cases with jasmine and karma for angular 2. But due to some issues I couldn't run using karma framework. Is it possible to write unit test cases for angular 2 application without using any external framework? Just simple…
user2301
  • 1,857
  • 6
  • 32
  • 63
0
votes
1 answer

Test angular2 http service

I am starting to learn angular2. Have a service with the following implementation: @Injectable() export class PostsService { constructor(private http: Http) { } getAllPosts() { return this.http.get('/api/posts') …
Igor L.
  • 3,159
  • 7
  • 40
  • 61
0
votes
1 answer

How to add a specs for checking ion-title, ion-content with Karma/Jasmine?

I am performing unit testing on Ionic2, using Karma/Jasmine. How to write specs for ion-title and ion-content?Will it be similar to how I wrote for h4 tag? And can we make the custom mocks for using in the test? homePage.html
Aditya
  • 2,358
  • 6
  • 35
  • 61
0
votes
1 answer

Angular 2 unit test for component

I am using ng2 with webpack 2. I cant figure out how to test component functions Here is my component import { Component, OnInit } from '@angular/core'; import { GlobalDataService } from '../global.service'; import { Router } from…
0
votes
1 answer

Karma setup don't see the .ts files

I have a big old project on Angular2, which I didn't start, and now I need to add tests there. I setup jasmine and karma, but, unfortunately, when I start "npm test", it don't see the .ts files, so I see the result only in .js-tests. Here are the…
0
votes
1 answer

Not able to start firefox for protractor automation angular 2 + angular cli

I am using the following npm command to run the automation tests. webdriver-manager clean && webdriver-manager update && ng e2e I have firefox as one of my multiCapabilities for protractor.conf.js. But I could not able to launch firefox. It is…
Irus
  • 81
  • 7
0
votes
0 answers

Unable to update the option for a select in safari for protractor with angular 2

I am working on automation using protractor for one of angular 2 application. I am able to get the option element what I want to select for a drop down. Note: I have tried many different ways to get the option from DOM. But I couldn't able to select…