MCPcopy Create free account
hub / github.com/denoland/std / hookFns

Function hookFns

testing/bdd_test.ts:46–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44let timerIdx = 1;
45const timers = new Map();
46function hookFns() {
47 timerIdx = 1;
48 timers.clear();
49 return {
50 beforeAllFn: spy(async function (this: GlobalContext) {
51 await Promise.resolve();
52 this.allTimer = timerIdx++;
53 timers.set(this.allTimer, setTimeout(() => {}, 10000));
54 }),
55 afterAllFn: spy(async function (this: GlobalContext) {
56 await Promise.resolve();
57 clearTimeout(timers.get(this.allTimer));
58 }),
59 beforeEachFn: spy(async function (this: GlobalContext) {
60 await Promise.resolve();
61 this.eachTimer = timerIdx++;
62 timers.set(this.eachTimer, setTimeout(() => {}, 10000));
63 }),
64 afterEachFn: spy(async function (this: GlobalContext) {
65 await Promise.resolve();
66 clearTimeout(timers.get(this.eachTimer));
67 }),
68 };
69}
70
71Deno.test("beforeAll(), afterAll(), beforeEach() and afterEach()", async () => {
72 using test = stub(Deno, "test");

Callers 2

bdd_test.tsFile · 0.85
assertHooksFunction · 0.85

Calls 4

spyFunction · 0.90
clearMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected