【发布时间】:2012-09-13 10:55:58
【问题描述】:
我是 JavaScript 的新手。我正在通过 Jasmine 的测试学习 Class。我试图通过测试,但尽管我努力了,但茉莉花并没有显示绿色。
我的代码如下:
// Generated by CoffeeScript 1.3.3
var Animal;
Animal = (function() {
function Animal() {}
Animal.prototype.walk = function() {
return 'tok tok...';
};
return Animal;
})();
测试代码如下:
// Generated by CoffeeScript 1.3.3
describe("Animal", function() {
var animal;
animal = new Animal;
it("shold walk", function() {
expect(animal.walk).toBe('tok tok...');
});
});
Jasmine 的消息如下:
Expected Function to be 'tok tok...'.
Error: Expected Function to be 'tok tok...'.
at new jasmine.ExpectationResult (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:102:32)
at null.toBe (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1194:29)
at null.<anonymous> (http://localhost:8888/__spec__/AnimalSpec.js:8:25)
at jasmine.Block.execute (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1024:15)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2025:31)
at goAgain (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2015:18)
我已经筋疲力尽了。谢谢你的好意...
【问题讨论】:
标签: javascript coffeescript jasmine