每当我运行单元测试时,我都会收到错误:
browser is not defined.
我的配置文件在下面 - 任何人都可以提出问题
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: [
'www-dev/js/ionic.bundle.js',
'node_modules/angular-mocks/angular-mocks.js',
'www-dev/js/app.js',
'www-dev/js/templates.js',
'www-dev/css/*.css',
{pattern: 'tests/unit/unit.js', nocache: true, watched: true}
],
// 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: {
'./www-dev/js/app.js': ['coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress','coverage'],
coverageReporter: {
type : 'html',
dir : './tests/unit/'
},
// 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: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome', 'Firefox', 'IE'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
答案 0 :(得分:0)
要实际打开浏览器实例,Karma需要一个浏览器启动器,它以插件的形式出现。
注意:大多数浏览器启动器都需要作为插件加载。
您是否安装了正确的启动器插件?