2017-10-31 2 views
0

에서 Sinon/모카와 변수를 조롱하는 방법이 내 코드입니다Node.js를

var sinon = require('sinon'); 
var start_end = require('./start_end'); 

describe("start_end", function(){ 
    before(function() { 
     cb_spy = sinon.spy(); 
    }); 

    afterEach(function() { 
    cb_spy.reset(); 
    }); 

    it("start_pool()", function(done){ 
    // how to make timer variable < 1, so that if(timer < 1) will meet 
    start_end.start_pool(cb_spy); 
    sinon.assert.calledWith(cb_spy, null, "hello world"); 

    }); 
}); 

함수 내에서 변수 timerglb_obj를 변경하는 방법 죄송한데?

답변

0

Sinonv4.1.2 현재로서는 사용할 수 없습니다.

Sinon은 내부 상태를 변경하는 대신 스터 빙 및 조롱을 통해 동작을 테스트하는 데 중점을 둡니다. 당신은 개인 변수의 값을 변경하려면


, rewire 같은 것을 사용하여 조사 :

https://github.com/jhnns/rewire