Jasmine无法执行,但Karma可以正常使用DESCRIBE

时间:2017-10-22 13:53:32

标签: angular jasmine karma-jasmine

这是我尝试在Jasmine上运行的spec.ts文件:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgForm, FormsModule } from "@angular/forms";
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './myWebApp.component';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [ BrowserModule, FormsModule ],
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  }));

并且在Chrome控制台中失败并显示以下错误:

Error: TypeError: require is not a function
    Evaluating https://npmcdn.com/@angular/forms@2.4.0/index.js
    Error loading https://npmcdn.com/@angular/forms@2.4.0/index.js as "@angular/forms" from https://run.plnkr.co/yr4o5FIKlm3GQRaj/myWebApp.component.spec.ts

一切都在Karma上运作良好。 现在我发表评论

// imports: [ BrowserModule, FormsModule ],

然后它至少开始工作但未通过测试。我是否需要在Jasmine中调整以避免上述错误并执行测试?

0 个答案:

没有答案