/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/specs/test/hooks/mixed_errors.ts
44 строки
909 B
Bartek Iwańczuk
feat(test): Add setup and teardown APIs to `Deno.test` API (#30504)
02 сен 2025, 17:27
Не верифицирован
02 сен 2025, 17:27
9fac6cc
Код
Авторство
О чём код?
let testCount = 0; const logs: string[] = []; Deno.test.beforeEach(() => { testCount++; logs.push(`beforeEach executed for test ${testCount}`); if (testCount === 3) { throw new Error("beforeEach failed for test 3"); } }); Deno.test.afterEach(() => { logs.push(`afterEach executed for test ${testCount}`); if (testCount === 4) { throw new Error("afterEach failed for test 4"); } }); Deno.test("test 1 - should pass", () => { logs.push("test 1 executed"); }); Deno.test("test 2 - should pass", () => { logs.push("test 2 executed"); }); Deno.test("test 3 - beforeEach fails", () => { logs.push("test 3 executed"); }); Deno.test("test 4 - afterEach fails", () => { logs.push("test 4 executed"); }); Deno.test("test 5 - test itself fails", () => { logs.push("test 5 executed"); throw new Error("test 5 failed"); }); globalThis.onunload = () => { console.log(logs); };