[英]Angular2 rc.6 Karma Testing
Im new to the whole TTD with karma and jasmin, Im trying to run a test on my service which pull data from my DB, but I keep getting errors saying that ReferenceError: Can't find variable: beforeEachProviders in karma-test-shim.js here is my test below.. 我是使用karma和jasmin对整个TTD陌生的,我试图在我的服务上运行测试以从数据库中提取数据,但是我不断收到错误消息,指出ReferenceError:无法找到变量:karma-test-shim中的beforeEachProviders。 js这是我下面的测试。
import { TracksServices } from './tracks.services.ts';
describe('Service: TracksServices', () => {
let service;
//setup
beforeEach(() => TestBed.configureTestingModule({
imports: [ TracksModule, HttpModule ],
providers: [
TracksServices
],
}));
it('get 4 featured images', done => {
service.featured(1, 4).subscribe(x => {
expect(x).toContain(track);
expect(x.length).toEqual(4);
done();
});
});
});
testing API in RC6 littel bit chaged. RC6的测试API有点麻烦。
for example changes in angular2-webpack-starter. 例如angular2-webpack-starter中的更改。
import { inject, TestBed } from '@angular/core/testing';
// Load the implementations that should be tested
import { App } from './app.component';
import { AppState } from './app.service';
describe('App', () => {
// provide our implementations or mocks to the dependency injector
beforeEach(() => TestBed.configureTestingModule({
providers: [
AppState,
App
]
}));
it('should have a url', inject([ App ], (app: App) => {
expect(app.url).toEqual('https://twitter.com/AngularClass');
}));
});
beforeEachProvider is removed and now using TestBed.configureTestingModule() where u should set provides: [] 删除了beforeEachProvider并现在使用TestBed.configureTestingModule(),其中应设置u提供以下内容:[]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.