0
我正在嘗試在打字稿項目中使用sinon並嘗試使用它的沙盒裝箱功能。我已經在建議的莊園中包裝了我的測試,我正在嘗試按照文檔致電this.stub(/stuff/)
。Sinon.test與打字稿這是空的對象
不幸的是,當我這樣做時,我得到以下錯誤TypeError: this.stub is not a function
。作爲一個測試,我打印this
控制檯之前的存根(stub),它是一個空對象。
下面是我嘗試編寫的測試失敗的一個示例。我們非常感謝任何有關爲了使沙盒功能正常工作而需要作出的更改的建議。
import * as sinon from 'sinon'
import * as fs from 'fs'
describe("test",()=>
it("raise error notification if location does not exist", sinon.test(()=>{
this.stub(fs,"existsSync",(location: string)=> false)
/* rest of test */
}))
})
未使用沙箱功能並手動還原存根可供參考。儘可能限制手動清理。
份額興農進口其他行調用像'*進口從「興農」興農;' –
@Venkatraman我更新的代碼,包括我的兩個包括saryments以及describe塊。 –