小编jor*_*ins的帖子

在angular2和jasmine中运行测试时,无法在TestBed.createComponent中读取null的属性'injector'

当使用karma和browserify运行简单测试时,我的测试在TestBed.createComponent()函数内崩溃.

这是崩溃的beforeEach:

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By }              from '@angular/platform-browser';
import { DebugElement }    from '@angular/core';
import { AboutPage } from './about'


beforeEach(() => {

    // refine the test module by declaring the test component
    TestBed.configureTestingModule({
      declarations: [ AboutPage ],
    });

    // create component and test fixture
    fixture = TestBed.createComponent(AboutPage);

    // get test component from the fixture
    comp = fixture.componentInstance;
  });
Run Code Online (Sandbox Code Playgroud)

并收到错误:

Chrome 53.0.2785 (Mac OS X 10.11.6) About component should display original title FAILED …
Run Code Online (Sandbox Code Playgroud)

unit-testing browserify karma-jasmine angular

5
推荐指数
1
解决办法
4293
查看次数

标签 统计

angular ×1

browserify ×1

karma-jasmine ×1

unit-testing ×1