Trying to incorporate sinon into a TypeScript project and make use of its sandboxing capabilities. I have followed the suggested approach to wrap my tests, but encountered an issue when trying to call this.stub(/<em>stuff</em>/)
according to the documentation.
Unfortunately, I keep receiving an error message stating
TypeError: this.stub is not a function
. In an attempt to troubleshoot, I logged this
to the console before the stub and found it to be an empty object.
Provided below is a sample of the failing test that I am attempting to write. Any insights on modifications necessary to enable the sandboxing feature would be greatly valued.
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 */
}))
})
While manually restoring the stubs instead of using the sandbox features does work for reference, I am aiming to minimize manual cleanup in the tests whenever feasible.