Ionic2,Jasmine,Karma单元测试
我们正在为Ionic2项目建立一个单元测试框架 在运行npm测试时,我们面临以下错误。 我在下面给出了src/.ts和src/.spec.ts以及cmd窗口错误 请帮忙解决 Chrome 55.0.2883 Windows 8.1 0.0.0错误:错误{拒绝:'失败 若要加载app.html',promise:ZoneAwarePromise{{uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu状态:0, __zone_symbol_值:'未能加载app.html'},z one:zone{{u属性:对象{},_父对象:null,_名称:, _zoneDelegate:zoneDelegate{t askCounts:…,zone:…,\u parentDelegate:…,\u forkZS:…,\u forkDlgt:…,\u interceptZS:…,\u interceptDlgt:…,\u invokeZS:…,\u invokeDlgt:。。。, _handleErrorZS:…,\u handleErrorDlgt:…,\u scheduleTaskZS:…,\u scheduleTaskDlgt:…,\u invokeTaskZS:…,\u invokeTaskDlgt:。。。, _cancelTaskZS:…,\u cancelTaskDlgt:…,\u hasTaskZS:…,\u hasTaskDlgt:…},任务:区域任务{runCount:1,键入:'microTask',区域:区域{属性:…,\u父级:…,\u名称:…,\u区域egate: …},来源:'Promise.then',数据:未定义,调度fn:未定义, cancelFn:null,ca llback:function{…},invoke:function{ …}}} Chrome 55.0.2883 Windows 8.1 0.0.0仪表板服务应返回 非空数组失败类型错误:无法读取属性“assertPresent” 在resetFakeAsyncZone处未定义的 C:/Users/user/AppData/Local/Temp/karma类型脚本包 -66485eOt1ZMUGTWZ.js:143884:22 at对象。C:/Users/user/AppData/Local/Temp/karma类型脚本包 -66485eOt1ZMUGTWZ.js:144536:13错误:异步测试帮助程序需要ProxyZoneSpec,但找不到。请确保 您的环境包括runInTestZone中的zone.js/dist/proxy.js C:/Users/user/AppData/Local/Temp/karma-typescript-bundle-6648 5eOt1ZMUGTWZ.js:143659:19 at对象。 C:/Users/user/AppData/Local/Temp/karma类型脚本包 -66485eOt1ZMUGTWZ.js:143633:17 TypeError:无法读取对象处null的属性“getData”。Ionic2,Jasmine,Karma单元测试,jasmine,ionic2,karma-jasmine,Jasmine,Ionic2,Karma Jasmine,我们正在为Ionic2项目建立一个单元测试框架 在运行npm测试时,我们面临以下错误。 我在下面给出了src/.ts和src/.spec.ts以及cmd窗口错误 请帮忙解决 Chrome 55.0.2883 Windows 8.1 0.0.0错误:错误{拒绝:'失败 若要加载app.html',promise:ZoneAwarePromise{{uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu状态:0, __zone_symbol_值:'未能加载app.html'
src/pages/dashboard/dashboard.spec.ts:47:35 在我的karma.conf中,我将一些附加文件加载到浏览器中:
// list of files / patterns to load in the browser
files: [
'../node_modules/zone.js/dist/zone.js', // 'Uncaught ReferenceError: Zone is not defined'
'../node_modules/zone.js/dist/proxy.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
'../node_modules/zone.js/dist/sync-test.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
'../node_modules/zone.js/dist/jasmine-patch.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
// ANY OTHER FILES TO LOAD FOR YOUR TESTS
],
import { Component, OnInit } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { AzureDatasync } from '../../app/providers/azure-datasync';
import 'zone.js/dist/async-test';
/*
Generated class for the Dashboard page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-dashboard',
templateUrl: 'dashboard.html'
})
export class DashboardPage implements OnInit {
todays: any ;
ticklers: any;
cases: any;
constructor(public navCtrl: NavController, public navParams: NavParams, public datasync: AzureDatasync) {}
ngOnInit(){
this.getData();
}
getData() {
this.todays = [
{type: "abc", name: "test", duration: "9.30 AM - 10.00 AM"},
{type: "def", name: "test2", duration: "12.45 AM - 3.10 PM"}
];
this.ticklers = [
{name: "abc", description: "A Court "},
{name: "def", description: "dd"}
];
this.cases = [
{name: "Msh", duedate: "Due on 7th Dec", priority: "PsI", timeduration: "24hrs", imgurl:"_blank.png"},
{name: "ss Smith", duedate: "Due on 11th Dec", priority: "Pris", timeduration: "30 mins ", imgurl:"./person_blank.png"}
];
}
}
// list of files / patterns to load in the browser
files: [
'../node_modules/zone.js/dist/zone.js', // 'Uncaught ReferenceError: Zone is not defined'
'../node_modules/zone.js/dist/proxy.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
'../node_modules/zone.js/dist/sync-test.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
'../node_modules/zone.js/dist/jasmine-patch.js', // 'TypeError: Cannot read property 'assertPresent' of undefined'
// ANY OTHER FILES TO LOAD FOR YOUR TESTS
],