angular2-testing Questions
2
Solved
I am new to Jasmine with Angular 2, I am frequently working with the TestBed object when writting a Testcase and getting the error:Please call "TestBed.compileComponents" before your test.
How do...
Harrietteharrigan asked 6/10, 2016 at 6:10
4
I am working on component testing with angular2.
in my html template i use the translate pipe.
This is the code of the test :
import { ComponentFixture, TestBed ,getTestBed} from '@angular/core/...
Shute asked 20/9, 2016 at 15:21
4
Solved
I am trying to test my component with angular 2 final, but I get an error because the component uses the routerLink directive. I get the following error:
Can't bind to 'routerLink' since it isn'...
Leucoderma asked 19/9, 2016 at 16:33
13
Solved
I am unit testing a component that is used to edit an object. The object has an unique id that is used in order to grab the specific object from an array of objects that are hosted in a service. Th...
Wynn asked 13/7, 2016 at 15:36
2
Solved
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:
i...
Mercantilism asked 27/1, 2022 at 15:5
4
Solved
Given the following code I try to test the ngOnChanges lifecycle hook of Angular2:
import {
it,
inject,
fdescribe,
beforeEachProviders,
} from '@angular/core/testing';
import {TestComponentBu...
Katakana asked 24/5, 2016 at 8:58
4
Solved
Let's say I have a component that subscribes to a service function:
export class Component {
...
ngOnInit() {
this.service.doStuff().subscribe(
(data: IData) => {
doThings(data);
},
(...
Malvoisie asked 10/10, 2016 at 14:4
6
Solved
I've run into missing <router-outlet> messages in other unit tests, but just to have a nice isolated example, I created an AuthGuard that checks if a user is logged in for certain actions.
T...
Jalbert asked 28/10, 2016 at 7:41
9
Currently I am overriding providers to use mocked services like this:
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
tcb.overrideProviders(AddFieldToObjectDropdownC...
Arroyo asked 2/9, 2016 at 13:9
2
I'm trying to test a basic angular 2 component that Includes a service. When I run my test I'm getting the following errors. The component, service and test are pretty small, they run fine in the b...
Wastrel asked 30/10, 2016 at 0:51
3
Solved
I have a text input and i'm listening for the changes.
mycomponent.ts
ngOnInit() {
this.searchInput = new Control();
this.searchInput.valueChanges
.distinctUntilChanged()
.subscribe(newValue ...
Impress asked 20/5, 2016 at 17:16
6
Solved
Context
I created an ApiService class to be able to handle our custom API queries, while using our own serializer + other features.
ApiService's constructor signature is:
constructor(metaManager: M...
Nathannathanael asked 13/9, 2016 at 14:20
2
Solved
I know that tick() function utilizes fakeAsync(). And also I can use fixture.whenStable().then() with async() and fakeAsync() as well.
I want to know the exact use case for both of them. Can anyone...
Berck asked 23/3, 2017 at 9:9
4
Solved
Suppose I have a component I want to test that uses a very complex component. Furthermore it calls some of its methods using references obtained by @viewChildren. For example
@Component({
module...
Bistort asked 29/11, 2016 at 0:33
3
Solved
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...
Motheaten asked 27/11, 2017 at 15:27
3
Solved
I've got a HighlightDirective which does highlight if the mouse enters an area, like:
@Directive({
selector: '[myHighlight]',
host: {
'(mouseenter)': 'onMouseEnter()',
'(mouseleave)': 'onMouse...
Improvvisatore asked 28/6, 2016 at 7:3
1
Solved
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.userI...
Hardwick asked 14/10, 2020 at 1:41
2
Solved
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 n...
Cocci asked 1/12, 2017 at 9:7
2
I would like to test component which implements ControlValueAccessor interface for allow to use [(ngModel)] in my custom component, but the issue is that usual inputs comes correct but ngModel - un...
Clem asked 16/6, 2017 at 9:13
3
Solved
i'm writing custom angular(Angular 2.0.0) validation, following this guide https://angular.io/docs/ts/latest/cookbook/form-validation.html#!#custom-validation .
@Directive({
selector: '[ngModel][...
Grating asked 7/10, 2016 at 5:25
2
Solved
I am trying to test angular2 two-way binding for control input. Here is the error:
Can't bind to 'ngModel' since it isn't a known property of 'input'.
The app.component.html
<input id="nam...
Colony asked 20/9, 2016 at 1:49
4
Solved
I have been reading official Angular2 documentation for unit testing (https://angular.io/docs/ts/latest/guide/testing.html) but I am struggling with setting a component's input field value so that ...
Stibine asked 9/12, 2016 at 14:48
2
Solved
I created a new project with NG-CLI (beta.15) and modified the app.component.spec to change the beforeEach to to a beforeAll and it caused the tests to fail with the following error:
Failed: Can...
Theorbo asked 28/9, 2016 at 13:21
4
Solved
I have an Angular2 component that contains a select box that looks like
<select [(ngModel)]="envFilter" class="form-control" name="envSelector" (ngModelChange)="onChangeFilter($event)">
<...
Savino asked 30/9, 2016 at 14:4
3
Solved
I am trying to write a test on a component which uses angular-material2, but when I add it to my testModule declarations I get:
Error: Template parse errors:
'md-card-title' is not a known elemen...
Farcy asked 26/10, 2016 at 17:46
1 Next >
© 2022 - 2024 — McMap. All rights reserved.