[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 ...
随机推荐
- OA项目笔记
一.创建项目构架 1.创建一个Maven的web工程 1.1修改编译器版本 <properties> <project.build.sourceEncoding>UTF-8&l ...
- chsh---更换登录系统时使用的shell
chsh命令 chsh命令用来更换登录系统时使用的shell.若不指定任何参数与用户名称,则chsh会以应答的方式进行设置. 语法 chsh(选项)(参数) 选项 -s<shell 名称&g ...
- centos6.5 数据库的安装
mongo https://www.cnblogs.com/layezi/p/7290082.html
- JNDI学习总结(3)——Tomcat下使用C3P0配置JNDI数据源
一.C3P0下载 C3P0下载地址:http://sourceforge.net/projects/c3p0/files/?source=navbar 下载完成之后得到一个压缩包. 二.使用C3P0配 ...
- 关于Blocking IO,non-Blokcing IO,async IO的区别和理解
来源:http://shmilyaw-hotmail-com.iteye.com/blog/1896683 概括来说,一个IO操作可以分为两个部分:发出请求.结果完成.如果从发出请求到结果返回,一直B ...
- 没有killall命令的解决方法
没有killall命令的解决方法 -bash: killall: command not found https://www.byte128.com/archives/231.html 执行killa ...
- js21---单体(单例)模式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- String类型转Long类型需要注意的问题
转自:https://blog.csdn.net/m819177045/article/details/52669785/
- STS清理
图中插入代码如下,文件名随意最好见名知意 Add 'this' qualifier to unqualified field accesses Add 'this' qualifier to unqu ...
- jQuery自定义插件规范
<ul class="list"> <li>导航列表 <ul class="nav"> <li>导航列表1< ...