Angularjs Angular CLI-Karma测试构建未找到ng2材料
我正在用Alpha Angular CLI构建一个新的Angular 2应用程序。我也在用图书馆。为了让它发挥作用,我必须做以下几点:Angularjs Angular CLI-Karma测试构建未找到ng2材料,angularjs,angular,karma-runner,karma-jasmine,angular-cli,Angularjs,Angular,Karma Runner,Karma Jasmine,Angular Cli,我正在用Alpha Angular CLI构建一个新的Angular 2应用程序。我也在用图书馆。为了让它发挥作用,我必须做以下几点: // index.html System.config({ packages: { app: { format: 'register', defaultExtension: 'js }, 'ng2-material': { format: 'cjs',
// index.html
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js
},
'ng2-material': {
format: 'cjs',
defaultExtension: 'js',
main: 'all.js'
}
}
});
System.import('app.js').then(null, console.error.bind(console));
// ember-cli-build.js
var materialTree = BroccoliFunnel('node_modules/ng2-material', {
destDir: 'ng2-material'
});
它在应用程序本身中运行良好。但是,当我运行ng test
时,我得到以下错误:
开始:
13 04 2016 14:55:36.982:警告[web服务器]:404:/ng2物料/全部
Chrome 49.0.2623(Mac OS X 10.11.3)错误
错误:XHR错误(未找到404)加载
13 04 2016 14:55:37.058:警告[web服务器]:404:/ng2材料/所有
我缺少什么?在您的
karma test shim.js中
在加载测试之前尝试加载模块:
System.import('system-config.js').then(function() {
// Load and configure the TestComponentBuilder.
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
testing.TestBed.initTestEnvironment(testingBrowser.BrowserDynamicTestingModule,
testingBrowser.platformBrowserDynamicTesting());
});
///////////////// Add this part /////////////////
}).then(function() {
return System.import('/path/to/ng2-material.js/in/node_modules');
/////////////////////////////////////////////////
}).then(function() {
// Finally, load all spec files.
// This will run the tests directly.
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
}));
}).then(__karma__.start, __karma__.error);
在
karma test shim.js中,在加载测试之前尝试加载模块:
System.import('system-config.js').then(function() {
// Load and configure the TestComponentBuilder.
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
testing.TestBed.initTestEnvironment(testingBrowser.BrowserDynamicTestingModule,
testingBrowser.platformBrowserDynamicTesting());
});
///////////////// Add this part /////////////////
}).then(function() {
return System.import('/path/to/ng2-material.js/in/node_modules');
/////////////////////////////////////////////////
}).then(function() {
// Finally, load all spec files.
// This will run the tests directly.
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
}));
}).then(__karma__.start, __karma__.error);