我正在尝试为一个小型演示项目设置Karma。问题是Karma没有执行任何测试用例。
我的项目只有两个.js
个文件:app/js/app.js
和test/spec/app.spec.js
我的业力配置文件如下:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: ['karma-jasmine','karma-phantomjs-launcher'],
files: [
'app/js/app.js',
'test/spec/app.spec.js',
],
exclude: [
],
preprocessors: {},
reporters: ['dots'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: true
});
};
我的app.spec.js
文件的临时内容是:
describe('app js', function(){
it('test');
});
我在我的项目中使用Gulp并编写了以下gulp任务进行测试:
gulp.task('test', function() {
gulp.src('app/js/**/*.js')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'watch'
}));
});
这是我在终端上运行gulp test
时所得到的:
Starting Karma server...
WARN `start` method is deprecated since 0.13. It will be removed in 0.14.
Please use
server = new Server(config, [done])
server.start()
instead.
11 01 2018 22:26:29.672:WARN [karma]: No captured browser, open http://localhost:9876/
11 01 2018 22:26:29.686:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
11 01 2018 22:26:29.687:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
11 01 2018 22:26:29.693:INFO [launcher]: Starting browser PhantomJS
11 01 2018 22:26:30.239:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected
on socket J2AB2rwIs49mJwRQAAAA with id 34572564
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0 secs / 0 secs)
任何人都可以让我知道我在这里做错了什么?