本文介绍了在Karma-mocha中没有定义chai的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用mocha-phantomjs配置成功运行我的测试用例。
现在我正在使用Karma启动器运行这些测试。
但我得到了问题 Chai未定义
。
I am running my test cases succesfully using mocha-phantomjs configurations.Now I am running these test using Karma launcher.But I get the issue Chai is not defined
.
这是我的配置文件。
module.exports = function(config) {
config.set({
client: {
mocha: {
ui: 'tdd'
}
},
basePath: '',
frameworks: ['mocha'],
files: [
'web/js/*.js',
'test/lib/*.js',
'node_modules/chai/chai.js' //added this on suggestion of the answer in stackoverflow
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Firefox'],
singleRun: false,
});
};
我已对此进行了研究,发现此,
I have researched on it and found this links,
推荐答案
我安装了业力 - chai
的chai插件
I installed the karma-chai plugin for chaihttps://github.com/eclifford/karma-chai-jquery/issues/3
将框架更改为此。
frameworks: ['mocha', 'chai']
并添加这些依赖项。
npm install karma-chai --save-dev
现在我已经解决了我的问题。
希望这对你也有帮助。
Now I have solved my problem.Hope this will help you also.
这篇关于在Karma-mocha中没有定义chai的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!