茉莉花初学者,茉莉花间谍的第一次尝试。我以为我在模仿格式显示在这里 http://pivotal.github.io/jasmine/(搜索:“andReturn”),但我收到一个无法解决的错误:
TypeError: Object function () {
callTracker.track({
object: this,
args: Array.prototype.slice.apply(arguments)
});
return spyStrategy.exec.apply(this, arguments);
} has no method 'andReturn'
不知道我做错了什么。这是我的规格:
describe('Die', function() {
it('returns a value when you roll it', function() {
var die = Object.create(Die);
spyOn(Math, 'random').andReturn(1);
expect(die.roll()).toEqual(6);
});
});
以及对应的JS:
var Die =
{
roll: function() {
return Math.floor(Math.random() * 5 + 1);
}
}
谢谢您的帮助!!!
jasmine 2.0 改变了一些间谍语法。茉莉花 2.0 文档 http://jasmine.github.io/2.0/introduction.html
spyOn(Math, 'random').and.returnValue(1);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)