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的更多相关文章

  1. Unit Testing, Integration Testing and Functional Testing

    转载自:https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional- ...

  2. PULPino datasheet中文翻译并给了部分论文注释(前四章:Overview、Memory Map、CPU Core、Advanced Debug Unit)

    参考: (1).PULPino datasheet:https://github.com/pulp-platform/pulpino/blob/master/doc/datasheet/datashe ...

  3. Difference Between Performance Testing, Load Testing and Stress Testing

    http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...

  4. Go testing 库 testing.T 和 testing.B 简介

    testing.T 判定失败接口 Fail 失败继续 FailNow 失败终止 打印信息接口 Log 数据流 (cout 类似) Logf format (printf 类似) SkipNow 跳过当 ...

  5. [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 ...

  6. [Angular Unit Testing] Shallow Pipe Testing

    import { TestBed, ComponentFixture } from '@angular/core/testing'; import { BrowserDynamicTestingMod ...

  7. [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 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. css相关用法

    1. 2. 3.offset([coordinates]) 获取匹配元素在当前视口的相对偏移. 返回的对象包含两个整型属性:top 和 left,以像素计.此方法只对可见元素有效. a.获取当前元素的 ...

  2. mybatis的XML返回值类型报错

    昨天项目里一直报错说是一个文件里的返回值java.util.hashmap不对,然后去定位这个文件发现并没有问题,后来在全局搜索的帮助下查找了返回值类型为resultMap的文件里看到写的代码里有: ...

  3. Python day3 知识总结

    if salary.isdigit(): salary = int(salary)判断输入的salary是否是一个整数是否成立 for index,item in enumerate(product_ ...

  4. Oracle学习总结(8)—— 面向程序员的数据库访问性能优化法则

    特别说明: 1.  本文只是面对数据库应用开发的程序员,不适合专业DBA,DBA在数据库性能优化方面需要了解更多的知识: 2.  本文许多示例及概念是基于Oracle数据库描述,对于其它关系型数据库也 ...

  5. [置顶] Docker学习总结(2)——Docker实战之入门以及Dockerfile(二)

    csphere/php-fpm:5.4 # cd docker-training/php-fpm/ # ls Dockerfile nginx_nginx.conf supervisor_nginx. ...

  6. wordpress 加速主题的静态资源

    wordpress 加速主题的静态资源(固定的CSS.JS和图片等) wordpress 中用函数 get_stylesheet_directory_uri() 生成当前主题的 URL , 格式如 h ...

  7. php 函数 pathinfo() 在分析文件名时,会含有上级目录

    php 函数 pathinfo() 在分析文件名时,会含有上级目录对一些含有中文的多级目录,这个函数取得的文件名可能会包含上级目录,

  8. error while loading shared libraries: libpcre.so.0的解决办法

    error while loading shared libraries: libpcre.so.0的解决办法 http://blog.csdn.net/xjkwq1qq/article/detail ...

  9. Atcoder At Beginner Contest 068 D - Decrease (Contestant ver.)

    D - Decrease (Contestant ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem S ...

  10. vim学习2

    进入插入模式: 在插入模式下删除: 寄存器