【问题标题】:Karma not running jasmine specs业力没有运行茉莉花规格
【发布时间】:2015-09-01 17:59:19
【问题描述】:

我正在建立一个新项目并试图让业力发挥作用。当我运行业力时,它会不断报告:

已执行 0 个错误,共 0 个错误。

此时我的项目只包含几个 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);
    });
});

但它仍然显示 Executed 0 of 0。如果我指定了 jasmine 框架并指定了 jasmine 插件,为什么它看不到并执行此测试?

【问题讨论】:

    标签: karma-runner karma-jasmine


    【解决方案1】:

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

    【讨论】:

    • 天啊!我怎么没看到。谢谢。
    猜你喜欢
    • 2014-12-12
    • 1970-01-01
    • 2017-02-10
    • 2017-01-15
    • 1970-01-01
    • 2016-02-17
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    相关资源
    最近更新 更多