我正在尝试使用有角度2和类型记录的业力/茉莉花/系统to来运行测试。我以前让它在没有系统it /类型记录的情况下使用babel。
我还让它在不使用系统it的情况下工作,将类型记录转换到es6,并使用相同的业力设置。
我想使用系统‘m,我不想做两次transpile,所以现在我尝试使用带业力的系统’m。(使用业力-system.js)。
我得到的错误是:
Error: XHR error (404 Not Found) loading /path/to/project/angular2/core.js
不管出于什么原因,业力/系统is没有在node_modules目录中寻找角度,而且我不想硬编码到我的项目文件中。
karma.conf.js:
module.exports = function(config) {
config.set({
basePath: '',
plugins: ['karma-systemjs', 'karma-jasmine', 'karma-chrome-launcher'],
frameworks: ['systemjs', 'jasmine'],
files: [
'client/**/*.spec.js',
'client/**/**/*.spec.js',
'server/**/*.spec.js',
'server/**/**/*.spec.js'
],
exclude: [
'node_modules/',
'client/node_modules/*',
'client/node_modules/**/*.spec.js',
'server/node_modules/*'
],
preprocessors: {},
systemjs: {
configFile: 'system.conf.js',
serveFiles: [
'client/**/*.js',
'server/**/*.js',
],
config: {
defaultJSExtensions: true
}
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: false,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}system.conf.js
System.config({
paths: {
'systemjs': 'node_modules/systemjs/dist/system.js',
'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.js',
'es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js'
}
});在我的打字记录文件中,我像这样加载角核。
import { Component, View } from 'angular2/core';
它被转移到:
System.register(['angular2/core'], function(exports_1) {
我尝试过在我的systemjs配置中添加一个baseUrl,它似乎什么也不做。
我已经搜索了几个小时了。我看过How to configure karma and systemjs to run tests for angular ES6 transpiled by traceur into amd format ES5 modules和Angular and ES6: Karma Testing with SystemJS,但仍然没有解决这个问题。
发布于 2015-12-24 10:49:57
在system.conf.js文件中,您应该为所有角度模块定义一个路径,如下所示:
System.config({
paths: {
'angular2/*': 'node_modules/angular2/bundles/*.js',
}
});https://stackoverflow.com/questions/34422036
复制相似问题