Karma读取我的测试但没有返回任何结果

时间:2016-12-21 14:56:54

标签: jasmine karma-jasmine

这很奇怪。我尝试了非常简单的例子。 Karma将阅读我的测试。但拒绝说出它们是否在输出中通过或失败。

这是我的配置文件:

// Karma configuration
// Generated on Mon Dec 19 2016 15:50:01 GMT-0500 (Eastern Standard Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '/src/tt',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    //plugins
    plugins: [
        'karma-jasmine',
        'karma-chrome-launcher',
        'karma-phantomjs-launcher',
        'karma-istanbul',
        'karma-coverage'
    ],

    // list of files / patterns to load in the browser
    files: [
    //'server/src/main/resources/webapp/static/app/**/*.js'
    //'server/src/main/resources/webapp/static/app/test-view/test-view-controller.spec.js',
        'test.spec.js'
    ],


    // list of files to exclude
    exclude: [
        //'bower_components',
        //'node_modules',
        //'server/src/main/resources/webapp/static/bower/**/*'
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      //'/**/!(*spec).js': ['coverage'],

    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: [],
    //reporters: [ 'coverage'],


    // 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_DEBUG,


    // 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'],
    browsers: ['PhantomJS'],


    // 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
  })
}

这是我的测试文件:

'use strict'

describe('test', function() {
    it('has to equal 4',
        function() {
        expect(3).toEqual(4);
    });
});

我错过了一些基本的东西吗?我昨天下午花了很多时间试图让一个测试运行起来,而我还不知道还有什么可以做的。

这是调试输出,所以我知道我正在加载我的测试文件,但没有结果。

21 12 2016 09:44:19.051:DEBUG [web-server]: serving (cached): c:/src/TT/node_mod
ules/karma-jasmine/lib/adapter.js
21 12 2016 09:44:19.054:DEBUG [middleware:source-files]: Requesting /base/test.s
pec.js?25b2b285aaae5dc1b28e003730ae0711891ed68b /
21 12 2016 09:44:19.055:DEBUG [middleware:source-files]: Fetching c:/src/tt/test
.spec.js
21 12 2016 09:44:19.056:DEBUG [web-server]: serving (cached): c:/src/tt/test.spe
c.js
21 12 2016 09:44:19.075:DEBUG [karma]: Run complete, exiting.
21 12 2016 09:44:19.078:DEBUG [launcher]: Disconnecting all browsers
21 12 2016 09:44:19.090:DEBUG [launcher]: Process PhantomJS exited with code 0
21 12 2016 09:44:19.091:DEBUG [temp-dir]: Cleaning temp dir c:\AppData\Local\Tem
p\karma-63269551
21 12 2016 09:44:19.097:DEBUG [launcher]: Finished all browsers

谁想让我感到愚蠢,并指出那些毁了我一天的逗号或引用?

1 个答案:

答案 0 :(得分:1)

好的,所以我终于找到了自己的答案(信用证):Need proper reporter for karma jasmine

如果你想让测试结果打印到控制台输出,那么较新的茉莉/业力需要你帮助karma-spec-reporter。考虑到我曾经使用的所有业力是幻象,很难说我的测试实际上运行得很好。加重但希望这有助于其他人也陷入困境。