我正在使用def time
"#{pad(min)}:#{pad(sec)}"
end
。
我是角色和业力的新手,并尝试进行一些单元测试。 Karma抛出一个错误:
Chrome 55.0.2883(Windows 10 0.0.0)日志:'警告:尝试加载 角度不止一次。' Chrome 55.0.2883(Windows 10 0.0.0)Youtube api服务应该从长youtube链接FAILED获取ID TypeError:(0,_youtube2.default)不是函数 在对象。 (C:/projects/angular-videos-library/app/src/library/api/apis.spec.js:60:40) TypeError:无法读取属性' getId'未定义的 在对象。 (C:/projects/angular-videos-library/app/src/library/api/apis.spec.js:66:24) Chrome 55.0.2883(Windows 10 0.0.0):执行1 of 1(1 FAILED)ERROR (0.007秒/0.003秒)22 01 2017 05:13:37.949:INFO [Firefox 50.0.0 (Windows 10 0.0.0)]:在带有id的套接字sCXEu8pu8MCh8QJ-AAAB上连接 21147日志:'警告:尝试不止一次加载角度。'火狐 50.0.0(Windows 10 0.0.0)Youtube api服务应从长youtube链接FAILED获取ID TypeError:_youtube2.default不是C中的函数:/projects/angular-videos-library/app/src/library/api/apis.spec.js (第60行) [0] /
此处ES6, angular 1.5.8, webpack(babel-loader)
:
apis.spec.js
import YoutubeService from './youtube.service';
describe('Youtube api service', () => {
let YtService;
beforeEach(() => {
YtService = YoutubeService();
});
it('should get an ID from long youtube link', () => {
let link = 'https://www.youtube.com/watch?v=TFeSNOdNtyo';
let id = YtService.getId(link);
expect(id).toBe('TFeSNOdNtyo');
});
});
:
karma.conf.js
我该如何解决?
现在,在亚历山大一世提出的修改后,我发现了这样的错误:
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'node_modules/angular/angular.min.js',
'app/src/app.module.js',
'app/src/**/*.spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'app/src/**/*.js': ["webpack"],
'app/src/**/*.spec.js': ["webpack"]
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome', 'Firefox'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
webpack: {
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['ng-annotate', 'babel?presets[]=es2015'] // 'babel-loader' is also a valid name to reference
}]
}
}
})
}