我是 JavaScript 的新手。我正在通过 Jasmine 的测试学习 Class。我试图通过测试,但尽管我很努力,但 Jasmine 并没有显示绿色。
我的代码如下:
// 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)
我累死。谢谢你的好意...