Karma没有运行茉莉花规格

时间:2014-11-01 18:26:45

标签: karma-runner karma-jasmine

我正在建立一个新项目并试图让业力发挥作用。当我经营业力时,它会继续报告:

  

执行0 of 0 ERROR。

此时我的项目只包含几个js文件和一个test.js文件。这是我的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: [
      {pattern: '../app/**/*.js', included: false},
      {pattern: '**/*.js', included: false}
    ],


    // 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: {
    },


    // 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_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'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    plugins: [
        'karma-jasmine',
        'karma-chrome-launcher',

    ]
  });
};

我可以通过打开日志调试来看到它正在加载我的测试文件,我看到了:

DEBUG [watcher]: Resolved files:
  ...
  c:/dev/forms/tests/forms/form-page-controller-tests.js
  ...

form-page-controller-tests.js的内容是:

describe("A suite", function() {
    it("contains spec with an expectation", function() {
        expect(true).toBe(true);
    });
});

然而它仍然说执行0为0.如果我指定了jasmine框架并指定了jasmine插件,为什么它没有看到并执行此测试?

1 个答案:

答案 0 :(得分:6)

您将{pattern: '**/*.js', included: false}声明为文件模式。这告诉业力不要加载任何JS文件,包括你的测试文件。 尝试将included更改为true