Epics can be unit-tested just like any other function in your application - they have a very specific set of inputs (the action$ stream) and the output is always an Observable. We can subscribe to this output Observable to assert that the actions goi…
The way to test router componet needs a little bit setup, first we need to create a "router-stubs.ts". This file is a helper file. // export for convenience. export { ActivatedRoute, Router, RouterLink, RouterOutlet} from '@angular/router'; impo…
Component: import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output } from '@angular/core'; @Component({ selector: 'stock-counter', changeDetection: ChangeDetectionStrategy.OnPush, template: ` <div class="stock-counter"> &l…
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; import {StockCounterComponent} from './stock-counter.component'; Te…
import { Http, Response, ResponseOptions } from '@angular/http'; import { TestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; import { Observa…
Recently I am blocked by a very weird issue, from the VS installed machine, I can run performance testing which was distributed to multiple test agents successfully, but if try to run API testing, it is always failed, I have tried run in VS and also…
HTML: <div ng-focus="vm.onFocus(month)", aria-focus="{{vm.focus == month}}", ng-keydown="vm.onKeydown($event, month)"> Component Controller: onKeydown(e, num) { switch(e.which) { : // enter : { // Space e.preventDefault…
When using Ngrx, we need to know how to test the component which has Router injected. Component: import {Component} from '@angular/core'; import {FormGroup} from '@angular/forms'; import {Store} from '@ngrx/store'; import * as fromAuth from '../../re…
<div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use strict'; class CardTitleInformCtrl { constructor() { } } function CardTitleInformDirective() { return { restrict: 'EA', scope: {}, bindToController: { userInf…
The component test: describe('The component test', () => { let component, $componentController, $controller, $injector, $scope; beforeEach(module("componennts.module")); beforeEach(inject((_$componentController_, _$controller_, _$injector_, _…