()
| 44 | let timerIdx = 1; |
| 45 | const timers = new Map(); |
| 46 | function 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 | |
| 71 | Deno.test("beforeAll(), afterAll(), beforeEach() and afterEach()", async () => { |
| 72 | using test = stub(Deno, "test"); |
no test coverage detected