If sometime you want to log out the comonent html to see whether the html render correctly, you can do :

  1. import {TestBed, async, ComponentFixture} from '@angular/core/testing';
  2. import {AppComponent} from './app.component';
  3. import {AuFaInputComponent} from './lib/au-fa-input/au-fa-input.component';
  4. import {InputRefDirective} from './lib/common/input-ref.directive';
  5. import {DebugElement} from '@angular/core';
  6. import {By} from '@angular/platform-browser';
  7.  
  8. describe('AppComponent', () => {
  9.  
  10. let component: AppComponent,
  11. fixture: ComponentFixture<AppComponent>,
  12. el: DebugElement,
  13. emailField: DebugElement;
  14.  
  15. beforeEach(async(() => {
  16. TestBed.configureTestingModule({
  17. declarations: [
  18. AppComponent, AuFaInputComponent, InputRefDirective
  19. ],
  20. }).compileComponents();
  21. }));
  22.  
  23. beforeEach(() => {
  24.  
  25. fixture = TestBed.createComponent(AppComponent);
  26. component = fixture.debugElement.componentInstance;
  27. el = fixture.debugElement;
  28. emailField = el.query(By.css('#email-field'));
  29.  
  30. fixture.detectChanges();
  31. });
  32.  
  33. it('should include the correct email icon inside the email input', async() => {
  34. // debug a component html
  35. console.log(emailField.nativeElement.outerHTML);
  36. expect(emaailField.query(By.css('i.icon.fa.fa-envelope'))).toBeTruthy();
  37. });
  38. });

If you found that some tmeplate binding doesn't render, you might should add :

  1. 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. LuoguP4016 负载平衡问题(费用流)

    题目描述 G 公司有 n 个沿铁路运输线环形排列的仓库,每个仓库存储的货物数量不等.如何用最少搬运量可以使 n 个仓库的库存数量相同.搬运货物时,只能在相邻的仓库之间搬运. 输入输出格式 输入格式: ...

  2. centos7 docker镜像源设置

    由于docker他的镜像下载地址是国外官网源需要修改 添加 Docker 加速镜像(阿里云专属) 安装/升级你的Docker客户端 推荐安装1.10.0以上版本的Docker客户端,参考文档 dock ...

  3. 03004_SQL语句

    1.SQL语法 (1)数据库是不认识JAVA语言的,但是我们同样要与数据库交互,这时需要使用到数据库认识的语言SQL语句,它是数据库的代码: (2)结构化查询语言(Structured Query L ...

  4. 【Codeforces Round #426 (Div. 2) C】The Meaningless Game

    [Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...

  5. Gym - 100548C The Problem Needs 3D Arrays

    Problem C.   The Problem Needs 3D Arrays Time Limit: 6000MS Memory Limit: 262144KB 64bit IO Format: ...

  6. POJ——T 2796 Feel Good

    http://poj.org/problem?id=2796 Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15375   ...

  7. android图片特效处理之图片叠加

    这篇将讲到图片特效处理的图片叠加效果.跟前面一样是对像素点进行处理,可参照前面的android图像处理系列之七--图片涂鸦,水印-图片叠加和android图像处理系列之六--给图片添加边框(下)-图片 ...

  8. 升级你的Linux日志系统

    650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...

  9. Android之Socket的基于UDP传输

    接收方创建步骤: 1.  创建一个DatagramSocket对象,并指定监听的端口号 DatagramSocket socket = new  DatagramSocket (4567); 2. 创 ...

  10. [ Eclipse ] [ Problem ] Eclipse 無法開啟問題

    因為 Eclipse 在設定環境的過程掛掉太多次,擷取一些網路上優秀的文章當作備份 http://www.ewdna.com/2013/12/Eclipse-Loading-Workbench.htm ...