Created
August 24, 2020 06:55
-
-
Save samjoch/dbe62556f20a3d6573ec3d08104b14b3 to your computer and use it in GitHub Desktop.
sinon sandbox and avajs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ava, { TestInterface as TestI } from "ava"; | |
import { createSandbox, SinonSandbox } from "sinon"; | |
interface SinonContext { | |
sandbox: SinonSandbox; | |
} | |
export const test = ((test: TestI<SinonContext>): TestI<SinonContext> => { | |
test.beforeEach(t => { | |
t.context.sandbox = createSandbox(); | |
}); | |
test.afterEach(t => { | |
t.context.sandbox.restore(); | |
}); | |
return test; | |
})(ava); | |
// In your test: | |
// import { test } from './util'; | |
// test("hello world", t => t.true(true)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment