gpt4 book ai didi

karma-runner - Karma 没有运行 jasmine 规范

转载 作者:行者123 更新时间:2023-12-03 09:26:37 25 4
gpt4 key购买 nike

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

Executed 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);
});
});

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

最佳答案

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

关于karma-runner - Karma 没有运行 jasmine 规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26691626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com