deno/tests/specs/test/hooks/async_error.out
Bartek Iwańczuk 9fac6ccb8b
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
feat(test): Add setup and teardown APIs to Deno.test API (#30504)
This commit adds `Deno.test.beforeAll`, `Deno.test.beforeEach`,
`Deno.test.afterAll` and `Deno.test.afterEach` APIs. 

These APIs can be used to perform setup and teardown for test cases. 

The API is similar to the Vitest API: https://vitest.dev/api/#setup-and-teardown, 
with the main difference being that that `before*` hooks don't return a cleanup
function.
2025-09-02 16:27:04 +02:00

48 lines
1.4 KiB
Text

Check [WILDCARD]async_error.ts
running 3 tests from ./async_error.ts
first test ... ok ([WILDCARD])
second test (beforeEach fails) ... FAILED ([WILDCARD])
third test (afterEach fails) ... FAILED ([WILDCARD])
------- post-test output -------
[
"beforeAll started",
"beforeAll completed",
"beforeEach started for test 1",
"beforeEach completed for test 1",
"first test executed",
"afterEach started for test 1",
"afterEach completed for test 1",
"beforeEach started for test 2",
"afterEach started for test 2",
"afterEach completed for test 2",
"beforeEach started for test 3",
"beforeEach completed for test 3",
"third test executed",
"afterEach started for test 3",
"afterAll started",
"afterAll completed"
]
----- post-test output end -----
ERRORS
second test (beforeEach fails) => ./async_error.ts:46:6
error: (in promise) Error: Async error in beforeEach
setTimeout(() => reject(new Error("Async error in beforeEach")), 5);
^
at [WILDCARD]async_error.ts:18:31
third test (afterEach fails) => ./async_error.ts:50:6
error: (in promise) Error: Async error in afterEach
await Promise.reject(new Error("Async error in afterEach"));
^
at [WILDCARD]async_error.ts:30:26
FAILURES
second test (beforeEach fails) => ./async_error.ts:46:6
third test (afterEach fails) => ./async_error.ts:50:6
FAILED | 1 passed | 2 failed ([WILDCARD])
error: Test failed