【发布时间】:2016-04-21 10:56:43
【问题描述】:
运行 Karma 单元测试时,我收到以下错误:
Chrome 47.0.2526 (Linux 0.0.0) 错误
未捕获的类型错误:无法读取未定义的属性“_setAsap”
评估路径/node_modules/angular2/bundles/angular2-polyfills.min.js
加载路径/node_modules/angular2/bundles/angular2-polyfills.min.js时出错
karma.conf.js 包含如下内容:
// Karma configuration
// Generated on Tue Dec 08 2015 14:19:08 GMT-0600 (CST)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',
files: [
'node_modules/angular2/bundles/angular2-polyfills.min.js',
'node_modules/es6-shim/es6-shim.js',
'node_modules/systemjs/dist/system.js',
'node_modules/rxjs//Rx.js',
'node_modules/angular2/bundles/angular2.min.js',
'dist/components/uploader.js',
'dist/components/uploader.spec.js'
],
...
uploader.js 是从 TypeScript 编译的 JavaScript 文件,是一个 Angular2 组件。 Uploader.spec.js 是单元测试。我使用 Karma、SystemJS 和 Angular2 beta 来尝试设置单元测试。
查看 _angular2_polyfills.js_ 时,_setAsap 似乎指向模块 es6-promise。但是,即使我在文件列表中添加了node_modules/es6-promise/dist/es6-promise.js,它也不起作用。
【问题讨论】:
标签: angular karma-jasmine systemjs