What's the unit test behavior on command "mocha test.js" (Mocha/Chai/Sinon ES6)?
test.js:
const should = require('chai').should();
const sinon = require('sinon');
a=()=>{
return false;
}
b=()=>{
return true;
}
it('should work', ()=>{
sinon.spy(global, 'a');
sinon.stub(global, 'b').returns(false);
a().should.equal(false);
b().should.not.equal(true);
a();
a.callCount.should.equal(2);
b.callCount.should.equal(1);
});
- A. 1) should work
1 failing
Because a() returns undefined not false
- B. should work
1 passing
- C. 1) should work
1 failing
Because "a" has not the expected callCount
- D. 1) should work
1 failing
Because b() does not return the expected value