sinon

    0熱度

    1回答

    我有以下函數使用bind將上下文綁定到then鏈。當我嘗試和測試,它拋出 TypeError: redisClient.hgetallAsync(...).bind is not a function myFunc() { let self = this; return redisClient.hgetallAsync('abcde') .bind({ ap

    0熱度

    1回答

    我在陣營 - 終極版 export class IncrementalSearch extends React.Component { constructor(props) { super(props); this.onSearch$ = new Subject(); this.onChange = this.onChange.bind(this); } c

    0熱度

    1回答

    我試圖模擬一個節點模塊內的功能。但它不允許我。有任何想法嗎? // module A function foo(){ return 1; } function bar(){ return foo() + 1; } module.exports = {foo, bar} 在測試中... const a = require('a'); ... sinon.s

    0熱度

    1回答

    我試圖測試一個函數,調用連接到亞馬遜AWS的兩個其他函數。考慮到這一點,我不想調用稱爲AWS的真正函數 - 我試圖將它們存根。但是,每次運行我的測試時,它都會調用真正的函數而不是我的存根。 我有點新來測試,可能會失去一些東西,但無法找到任何其他問題的解決方案。 我使用jasmine和sinon 我的代碼如下:因爲我不 export function functionA(id: string): P

    1熱度

    1回答

    這裏是我的代碼: var startTime = new Date(startDateTime).toLocaleTimeString("en-US", options); 我需要得到startTime在我的單元測試。從java的角度瞭解單元測試,我會將此問題作爲如何模擬新的日期構造函數?然後如何模擬toLocaleTimeString函數調用?。但是,我不確定這是在javascript中處理

    3熱度

    1回答

    我正在使用Mocha和sinon間諜函數調用。該函數被正確調用,但間諜沒有跟蹤它。 這裏是我的測試 export default (() => { function test1(){ console.log('called second func'); return 5; } function callThis(){ conso

    -3熱度

    1回答

    我的代碼: it('should', sinon.test(function() { console.log(this); // what `this` refer here? ... })); 在上面的代碼,什麼this指在sinon.test()功能? 我試圖登錄,但是得到了錯誤: TypeError: Converting circular structure to

    0熱度

    1回答

    我的代碼: before(function _before() { this.myObject = new MyObject(); }); it('should', sinon.test(function() { const stubLog = sinon.stub(this.myObject.log, 'warn'); })); it(

    -3熱度

    1回答

    我的代碼: before(function _before(){ this.spyLog = sinon.spy(this.myOBJ.log, 'warn'); }); after(function _after(){ this.spyLog.restore(); }); it('should', sinon.test(functi

    1熱度

    1回答

    我正在學習sinon。我的代碼: const bluebird = require('bluebird'); const sinon = require('sinon'); const sinonTest = require('sinon-test')(sinon); sinon.test = sinonTest; describe('xxx', function _test() {