我正在尝试配置业力+摩卡+应该,但我一定是遗漏了什么,因为应该在我的测试中没有定义。
根据插件文档,要遵循的唯一步骤是:
1.-将应该添加到框架和业力中-应该在您的业力配置中插入键:
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'should'],
plugins: ['karma-should']
});
};测试中所有的断言都是可用的。
这是我的配置:
package.json
"devDependencies": {
"karma": "^0.13.3",
"karma-chrome-launcher": "^0.2.0",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.2.0",
"karma-phantomjs-launcher": "^0.2.0",
"karma-requirejs": "^0.2.2",
"karma-should": "0.0.1",
"mocha": "^2.2.5",
"should": "^7.0.2",
}karma.conf.js
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: ['mocha', 'should'],
plugins: ['karma-mocha',
'karma-should',
'karma-chrome-launcher',
'karma-firefox-launcher'],simpleTest.js
describe('theAnswer()', function() {
it('should be 42', function() {
theAnswer().should.be.exactly(42);
});
});
function theAnswer() {
return 42;
}当我运行karma start时,我得到:
Firefox 39.0.0 (Windows 7 0.0.0) theAnswer() should be 42 FAILED
theAnswer(...).should is undefined知道为什么吗??
发布于 2015-07-23 12:32:46
由于应7.x.x中的包更改,插件实现似乎出现了问题:
这里有一个打开的拉请求:https://github.com/seegno/karma-should/pull/1
当前插件版本(0.0.1)的工作原理应该是6.x.x。
编辑:最新业力-应该插件发布(1.0.0)纠正这个问题。
https://stackoverflow.com/questions/31586480
复制相似问题