sinon

    1熱度

    1回答

    我試圖從路由處理模擬功能... 這裏是我的路線: server.route({ method: 'GET', path: '/api/color/{format}', handler: this.pingLogic.getPing, config: { description: 'This is ping route', tags: ['

    1熱度

    1回答

    我正在嘗試編寫一個基本的單元測試以使用下面的函數,但無法使其工作。我如何測試像返回適當的npm-express響應? 我已經看過Using Sinon to stub chained Mongoose calls,https://codeutopia.net/blog/2016/06/10/mongoose-models-and-unit-tests-the-definitive-guide/和U

    0熱度

    1回答

    我正在使用CasperJS以及PhantomXHR。當我在webkit版本中運行代碼時,我可以模擬響應,但是同樣的腳本在Firefox中不能使用--engine = slimerjs。它啓動Firefox瀏覽器並顯示頁面錯誤,因爲window.sinon未定義。任何解決方案來擺脫這個問題。 PhantomXHR + sinon會支持slimerjs嗎?

    0熱度

    1回答

    我想砸自己的功能,並返回不同的ARGS不同的價值,這機能的研究使用一個回調 例如: function saop(){ saop.get('car',"http://webservice.com",function (err, result) {}); // (null, {car:"car"}) saop.get('house',"http://webservice.com",functio

    0熱度

    1回答

    我正在測試一個使用AVA和Sinon的小函數。功能基本上看起來像這樣(編輯爲簡潔起見): mergeDefaults: function (opts) { **console.log('log 1 ->', opts);** opts = _.defaultsDeep(opts, defaultOptions); return opts; } 我寫了一個測試,以

    0熱度

    1回答

    我正在嘗試使用sinon的Stub類屬性。 function wrapper() { this.obj = {"message":"hello"}; this.sendmessege = function() { console.log(this.obj.message); return "message is:" + this.obj.message;

    1熱度

    1回答

    我想模擬一個填充調用,我想模擬返回貓鼬對象,而不是普通的JS對象。 sandbox.mock(BookModel) .expects('populate') .yields(null, [ new BookModel({ _id: mongoose.Types.ObjectId(), name: 'Mock Book', autho

    0熱度

    1回答

    在這個指令,我想測試下: $scope.$on('loggedMsg', function(){ if($scope.users.length){ $scope.callingFn(); } }); 我能夠發出loggedMsg與$scope.apply(),它會調用$ scope.callingFn()。有沒有辦法實際調用$ scope.callingFn,

    0熱度

    1回答

    我想問一下,是否可以測試調用與sinon或mocha條件相關的正確函數。例如我有級騎士,我想知道當參數'data'爲true時是否調用函數(knightRun)。 export class Knight { createKnight(data,reducer) { if (data) { this.knightRun(reducer); }

    0熱度

    1回答

    我正在使用Angular-UI的$ uibModal在我的代碼中打開一個模式。在調用open方法之後,我定義了在open.then()中運行的代碼()& closed.then()承諾。所有這些工作正常,但是當試圖測試它(在Jasmine中)時,我無法弄清楚如何解決打開和關閉的承諾。 這裏是我用來打開模式(在我的控制器)代碼: function backButtonClick() { v