我有一个我正试图通过CI进行测试的测试套件。 (竹)
问题是这在我的本地系统上完全正常运行,但是我将它部署到Bamboo服务器(我无法自行配置)调用npm --harmony test
(--harmony
使用{{1 } {while const
)失败。
接下来,它返回以下errormessage
use strict
其中07-Oct-2016 16:37:03 07 10 2016 16:37:03.315:ERROR [preprocessor.rollup]: Could not resolve '../../services/apicaller.service' from /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/src/pages/events/events.component.ts
07-Oct-2016 16:37:03 at /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/config/karma-shim.ts
07-Oct-2016 16:37:03 Error: Could not resolve '../../services/apicaller.service' from /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/src/pages/events/events.component.ts
07-Oct-2016 16:37:03 at Error (native)
07-Oct-2016 16:37:03 at /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:78:21
07-Oct-2016 16:37:03 at /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/browser-resolve/index.js:265:24
07-Oct-2016 16:37:03 at /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/resolve/lib/async.js:55:18
07-Oct-2016 16:37:03 at load (/opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/resolve/lib/async.js:69:43)
07-Oct-2016 16:37:03 at onex (/opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/resolve/lib/async.js:92:31)
07-Oct-2016 16:37:03 at /opt/bamboo-home/xml-data/build-dir/MCAE-MANCAVE-JOB1/node_modules/resolve/lib/async.js:22:47
是../../services/apicaller.service
项目结构(缩小以匹配错误消息'范围)
src/pages/events/events.component
Karma.conf.js:
src
|
--config
| |
| --karma.conf.js
| --karma-shim.ts
| --protractor.conf.js
| --rollup.config.js
|
--pages
| |
| --events
| |
| --events.component.ts
|
--services
|
--APICaller.service.ts
噶shim.ts
'use strict';
const path = require('path');
const ts = require('rollup-plugin-typescript');
const buble = require('rollup-plugin-buble');
const nodeResolve = require('rollup-plugin-node-resolve');
const angular = require('rollup-plugin-angular');
const commonjs = require('rollup-plugin-commonjs');
const alias = require('rollup-plugin-alias');
module.exports = function karmaConfig(config) {
var configuration = {
// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: '../',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-phantomjs-launcher'),
require('karma-rollup-plugin')
],
reporters: [
// // Reference: https://github.com/mlex/karma-spec-reporter
// // Set reporter to print detailed results to console
// 'spec',
// // Reference: https://github.com/karma-runner/karma-coverage
// // Output code coverage files
// 'coverage'
'progress'
],
// list of files / patterns to load in the browser we are building
// the config environment in ./karma-shim.js
files: [
'config/karma-shim.ts'
],
preprocessors: {
'config/karma-shim.ts': ['rollup']
},
rollupPreprocessor: {
context: 'this',
plugins: [
angular({
exclude: 'node_modules/**'
}),
ts({
typescript: require('../node_modules/typescript')
}),
alias({
'@angular/core/testing': path.resolve(__dirname, '../node_modules/@angular/core/testing/index.js'),
'@angular/platform-browser-dynamic/testing': path.resolve(__dirname, '../node_modules/@angular/platform-browser-dynamic/testing/index.js'),
'@angular/compiler/testing': path.resolve(__dirname, '../node_modules/@angular/compiler/testing/index.js'),
'@angular/platform-browser/testing': path.resolve(__dirname, '../node_modules/@angular/platform-browser/testing/index.js')
}),
commonjs(),
nodeResolve({ jsnext: true, main: true, browser: true }),
buble()
]
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
// Continuous Integration mode if true, Karma captures browsers, runs the tests and exits
singleRun: true
};
// if(process.env.GITLAB_CI){
// //configuration.browsers = ['Chrome_travis_ci'];
// }
config.set(configuration);
};
rollup.config.js
declare var __karma__: any;
__karma__.loaded = () => { };
import 'core-js/client/shim';
import 'reflect-metadata';
import 'zone.js/dist/zone';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/proxy';
import 'zone.js/dist/jasmine-patch';
import 'rxjs/Rx';
import { TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
TestBed.initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
import '../src/pages/home/home.spec';
import '../src/pages/events/events.spec';
import '../src/pages/event-detail/event-detail.spec';
__karma__.start();
答案 0 :(得分:0)
我认为Bamboo区分大小写。由于我的APICaller
没有遵循角度kebab-case
,因此Bamboo无法找到路径。
班级为APICaller.service.ts
,导入为{..} from 'apicaller.service
。更改为{..} from 'APICaller.service
使其正常工作