Eri*_*rik 5 javascript mocha.js backbone.js sinon chai
我试图通过使用require.js/mocha/chai/sinon和骨干应用程序来攀登学习曲线.当我运行此测试时:
define([
"chai",
"sinon"
], function(chai, sinon){
var expect = chai.expect;
describe("Trying out the test libraries", function(){
describe("Chai", function(){
it("should be equal using 'expect'", function(){
expect(hello()).to.equal("Hello World");
});
});
describe("Sinon.JS", function(){
it("should report spy called", function(){
var helloSpy = sinon.spy(window, "hello");
expect(helloSpy.called).to.be.false;
hello();
expect(helloSpy.called).to.be.true;
hello.restore();
});
});
});
});
Run Code Online (Sandbox Code Playgroud)
我找到TypeError: Object #<Object> has no method 'spy' 了定义helloSpy的行.为什么?请注意,第一次测试通过.
这是完整的项目:
https://github.com/ErikEvenson/spa-testing-study/tree/bcc5b71b3b6f8b24f7e8d01673b50682498ee1b2.
注意使用该特定提交.
| 归档时间: |
|
| 查看次数: |
1864 次 |
| 最近记录: |