首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >狼吞虎咽跑业力测试-找不到变量:角度

狼吞虎咽跑业力测试-找不到变量:角度
EN

Stack Overflow用户
提问于 2015-04-05 22:49:11
回答 1查看 3.3K关注 0票数 1

当跑步吞咽的时候,测试运行的很好。在文件更改时,会抛出错误,然后运行并通过测试。如果我在运行测试的情况下拔出浏览器,它就会出错。我注意到文件没有像我指定的那样被送达。我的当前目录看起来很像app bower_components node_modules公共javascripts测试karma.conf.js

gulpfile.js

代码语言:javascript
复制
var gulp = require('gulp');
var karma = require('gulp-karma');
var shell = require('gulp-shell');

var testFiles = [

];

var serverDir = [
    './views/*.js',
    './test/**/*.js',
    './test/*.js',
    './routes/**/*.js',
    './routes/*.js',
    './models/**/*.js',
    './models/*.js',
    'app.js'
];

gulp.task('test', function() {
    // Be sure to return the stream
    return gulp.src(testFiles)
        .pipe(karma({
            configFile: 'public/javascripts/karma.conf.js',
            action: 'watch'
        }))
        .on('error', function(err) {
            // Make sure failed tests cause gulp to exit non-zero
            //throw err;
        });
});

gulp.task('default', ['test', 'testServer', 'watchServerFiles']);

gulp.task('watchServerFiles', function() {
    gulp.watch(serverDir, ['testServer']);
});
gulp.task('testServer', shell.task('jasmine-node-karma test/api.spec.js'));

karma.conf.js

代码语言:javascript
复制
    module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    files: [
        '../../bower_components/angular/angular.js',
        '../../bower_components/angular-mocks/angular-mocks.js',
        '../../bower_components/angular-resource/angular-resource.js',
        '../../bower_components/angular-route/angular-route.js',
        '../../bower_components/lodash/lodash.js',
        './app.js',
        './controllers/*.js',
        './directives/*.js',
        './services/*.js',
        './*.js',
        './test/*.js',
        './test/**/*.js'
    ],
    reporters: ['progress'],
    browsers: ['PhantomJS'],
    plugins: [
      'karma-jasmine',
      'karma-phantomjs-launcher'
    ],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    singleRun: false
  });
};
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-01 18:54:44

检查这个thread

大多数投票的答案都很好,但我决定用业力本身代替吞咽业力.优点是您不需要重复gulpfile.js和karma.conf.js文件中的文件列表。

代码语言:javascript
复制
var gulp = require('gulp');
var karma = require('karma').server;

gulp.task('tests', function(done) {
  return karma.start({
      configFile: __dirname + '/test/karma.conf.js',
      singleRun: true
    }, done);
});
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29463090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档