[Angular Unit Testing] Debug unit testing -- component rendering
If sometime you want to log out the comonent html to see whether the html render correctly, you can do :
- import {TestBed, async, ComponentFixture} from '@angular/core/testing';
- import {AppComponent} from './app.component';
- import {AuFaInputComponent} from './lib/au-fa-input/au-fa-input.component';
- import {InputRefDirective} from './lib/common/input-ref.directive';
- import {DebugElement} from '@angular/core';
- import {By} from '@angular/platform-browser';
- describe('AppComponent', () => {
- let component: AppComponent,
- fixture: ComponentFixture<AppComponent>,
- el: DebugElement,
- emailField: DebugElement;
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [
- AppComponent, AuFaInputComponent, InputRefDirective
- ],
- }).compileComponents();
- }));
- beforeEach(() => {
- fixture = TestBed.createComponent(AppComponent);
- component = fixture.debugElement.componentInstance;
- el = fixture.debugElement;
- emailField = el.query(By.css('#email-field'));
- fixture.detectChanges();
- });
- it('should include the correct email icon inside the email input', async() => {
- // debug a component html
- console.log(emailField.nativeElement.outerHTML);
- expect(emaailField.query(By.css('i.icon.fa.fa-envelope'))).toBeTruthy();
- });
- });
If you found that some tmeplate binding doesn't render, you might should add :
- fixture.detectChanges();
to trigger change detection.
[Angular Unit Testing] Debug unit testing -- component rendering的更多相关文章
- Unit Testing, Integration Testing and Functional Testing
转载自:https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional- ...
- PULPino datasheet中文翻译并给了部分论文注释(前四章:Overview、Memory Map、CPU Core、Advanced Debug Unit)
参考: (1).PULPino datasheet:https://github.com/pulp-platform/pulpino/blob/master/doc/datasheet/datashe ...
- Difference Between Performance Testing, Load Testing and Stress Testing
http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...
- Go testing 库 testing.T 和 testing.B 简介
testing.T 判定失败接口 Fail 失败继续 FailNow 失败终止 打印信息接口 Log 数据流 (cout 类似) Logf format (printf 类似) SkipNow 跳过当 ...
- [Angular + Unit Testing] Mock HTTP Requests made with Angular’s HttpClient in Unit Tests
In a proper unit test we want to isolate external dependencies as much as possible to guarantee a re ...
- [Angular Unit Testing] Shallow Pipe Testing
import { TestBed, ComponentFixture } from '@angular/core/testing'; import { BrowserDynamicTestingMod ...
- [Unit Testing] AngularJS Unit Testing - Karma
Install Karam: npm install -g karma npm install -g karma-cli Init Karam: karma init First test: 1. A ...
- [Unit Testing] Fundamentals of Testing in Javascript
In this lesson, we’ll get the most fundamental understanding of what an automated test is in JavaScr ...
- [Spring Unit Testing] Spring Unit Testing with a Java Context
For example, we want to test against a implemataion: package com.example.in28minutes.basic; import o ...
随机推荐
- LuoguP4016 负载平衡问题(费用流)
题目描述 G 公司有 n 个沿铁路运输线环形排列的仓库,每个仓库存储的货物数量不等.如何用最少搬运量可以使 n 个仓库的库存数量相同.搬运货物时,只能在相邻的仓库之间搬运. 输入输出格式 输入格式: ...
- centos7 docker镜像源设置
由于docker他的镜像下载地址是国外官网源需要修改 添加 Docker 加速镜像(阿里云专属) 安装/升级你的Docker客户端 推荐安装1.10.0以上版本的Docker客户端,参考文档 dock ...
- 03004_SQL语句
1.SQL语法 (1)数据库是不认识JAVA语言的,但是我们同样要与数据库交互,这时需要使用到数据库认识的语言SQL语句,它是数据库的代码: (2)结构化查询语言(Structured Query L ...
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
[Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...
- Gym - 100548C The Problem Needs 3D Arrays
Problem C. The Problem Needs 3D Arrays Time Limit: 6000MS Memory Limit: 262144KB 64bit IO Format: ...
- POJ——T 2796 Feel Good
http://poj.org/problem?id=2796 Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 15375 ...
- android图片特效处理之图片叠加
这篇将讲到图片特效处理的图片叠加效果.跟前面一样是对像素点进行处理,可参照前面的android图像处理系列之七--图片涂鸦,水印-图片叠加和android图像处理系列之六--给图片添加边框(下)-图片 ...
- 升级你的Linux日志系统
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...
- Android之Socket的基于UDP传输
接收方创建步骤: 1. 创建一个DatagramSocket对象,并指定监听的端口号 DatagramSocket socket = new DatagramSocket (4567); 2. 创 ...
- [ Eclipse ] [ Problem ] Eclipse 無法開啟問題
因為 Eclipse 在設定環境的過程掛掉太多次,擷取一些網路上優秀的文章當作備份 http://www.ewdna.com/2013/12/Eclipse-Loading-Workbench.htm ...