[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 ...
随机推荐
- mapper.xml中的常用标签
mybatis的mapper xml文件中的常用标签 https://blog.csdn.net/qq_41426442/article/details/79663467 SQL语句标签 1.查询语句 ...
- ssh-keygen && ssh-copy-id 生成管理传输秘钥
- Springboot2.0访问Redis集群
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作高性能的key-value数据库.缓存和消息中间件,掌握它是程序员的必备技能,下面是一个springboot访问redis的 ...
- 徒弟们对话,遇到sb领导,离职吧
由于涉及私密,所以qq号做了干扰.见谅. 非常多人以为在公司,你优化了几十个sql老板就给你涨工资了.或者你bbed搞点特殊恢复就涨工资了. 或者解决某些棘手问题就涨工资了. 那是不正确的. 遇 ...
- Oracle442个应用场景-----------Oracle数据库物理结构
-------------------------Oracle数据库物理结构------------------------------- Oracle数据库物理结构 oracle的数据,实际 ...
- UnrealEngine4针对游戏模式的思考
游戏能够概括为三类:单进程联机(超级玛丽).小规模联机(魔兽争霸.CS),大规模联机(魔兽世界). watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmx1c ...
- 2. APIS官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 2. APIS .APIS Apache Kafka引入一个新的java客户端(在o ...
- org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe
用weblogic 12c 测试 ejb3 import javax.naming.InitialContext; import javax.naming.NamingException; impor ...
- Android学习路线(十四)Activity生命周期——停止和重新启动(Stopping and Restarting)一个Activity
正确地停止和重新启动你的activity在activity的生命周期中是一个非常重要的过程.这样可以确保你的用户感觉到你的应用一直都活着而且没有丢失进度.你的activity的停止和重新启动时有几个重 ...
- Android学习之图片压缩,压缩程度高且失真度小
曾经在做手机上传图片的时候.直接获取相机拍摄的原图上传,原图大小一般1~2M.因此上传一张都比較浪费资源,有些场景还须要图片多张上传,所以近期查看了好多前辈写的关于图片处理的资料.然后试着改了一个图片 ...