Questions tagged [angular2-testing]
289 questions
0
votes
1 answer
Angular 2 Jasmine wait for timeout before continuing
In my code I have a method that returns a part object, however it returns the object inside a setTimeout method. When I attempt to test this I'm running into the issue that the test does not wait until the timeout has completed before it evaluates…

efarley
- 8,371
- 12
- 42
- 65
0
votes
1 answer
Angular2 test "provide => use value"
I have the following code to invoke angular2
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { AppModule } from "./src/app";
export function runAngular2App(legacyModel: any) {
platformBrowserDynamic([
…

Ajey
- 7,924
- 12
- 62
- 86
0
votes
1 answer
Test chain depended services
I want test some service AService, which has some dependencies BService, which is depended on another service e.x. CService. We have chain like dependencies:
AService --> BService --> CService
AService constructor:
constructor(
private bService:…

oto lolua
- 499
- 4
- 16
0
votes
1 answer
Angular2 unit testing a component that uses MdlSnackbarService
I've got the following component:
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, FormControl, Validators} from "@angular/forms";
import {ValidationService} from "../../services/validation.service";
import {Router}…

mario595
- 3,671
- 7
- 34
- 57
0
votes
0 answers
How to test this directive in Angular 2
I have this Directive that i apply to a component the directive works fine but now i want to write test cases for the same i am stuck at how to procede with writing the spec file please help
import {Directive, Input, HostListener} from…
user7161814
0
votes
1 answer
How do I access the scope data from an Angular2 DebugElement?
I'd like to cycle through DebugElements to ensure that the object described by the element has certain properties. For example, I may want to be sure that the display only shows those patients who have an appointment today and not the full list of…

Jared Clemence
- 1,062
- 11
- 26
0
votes
1 answer
Issue with jasmine expectations not being tested/evaluated because of simulated mock error
I am trying to unit test a angular 2 component and simulate an error (400/bad request) from the http backend.
Here is my code:
describe('Component: UserAccountActivationComponent', () => {
let fixture:…

balteo
- 23,602
- 63
- 219
- 412
0
votes
1 answer
Angular 2 - why ng test ignore TS compilation error?
i create some TS error in my test (spec file) such:
let num: number = "dsds".
i run the ng test and the test is successful... why?
i expected to get some TS error in the terminal
What i need to do to enable this behavior (the TS catch error) when…

Chen Reuven
- 79
- 9
0
votes
1 answer
Need assistance with Angular2 TestBed Configuration. DecoratorFactory errors
I am creating a test for a component named 'DashboardComponent'. The test spec is proving hard to create. Karma is throwing the error "Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule'".
I have tried removing code until…

Jared Clemence
- 1,062
- 11
- 26
0
votes
1 answer
Integrated testing vs Isolated testing in angular2
What are the major differences between Integrated testing
against Isolated testing ?
When are these used?

Aravind
- 40,391
- 16
- 91
- 110
0
votes
1 answer
Errors when e2e testing angular2 app with protractor
I'm trying to run some simple tests on my Angular2 app using protractor. I run ng serve in one command prompt and ng e2e in another. I get several errors/comments related to a session exception. Here is a portion of…

Drew13
- 1,301
- 5
- 28
- 50
0
votes
1 answer
Unit Test with Page object - tests running before Page html elements defined - Angular 2 Jasmine
I have applied the Angular 2 Page Object from the official docs to my tests to simplify setup.
In the docs and so also in my code it has a function called page.addElements that runs in a promise:
return fixture.whenStable().then(() => {
//…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
0
votes
2 answers
Angular2 quickstart: how should I include a new npm package?
I setup the environment by cloning the angular2 quick start repo: https://github.com/angular/quickstart. After I added new package into system.config.js file, the app runs but "npm test" failed. I noticed that there is an empty file named…

Ng2-Fun
- 3,307
- 9
- 27
- 47
0
votes
1 answer
Testing: How to lookup component instance for sub-component
I have a component I am testing that has a large number of subcomponents. In my test I would like to get a reference to the objects for some of these subcomponents to I can check their properties to see if they are behaving correctly and to…

Allen
- 3,134
- 5
- 29
- 49
0
votes
1 answer
Importing the Angular 2 testing classes ComponentFixture & TestBed causing 404 error
I get this error only when I try to run my jasmine tests. I run them with a spec runner html file.
zone.js:1382 GET
http://localhost:3002/node_modules/@angular/core/bundles/core.umd.js/testing
404 (Not Found)
zone.js:232 Error: (SystemJS) XHR…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287