From fb4a3c343573b0b3fd162e7e84da4c5d13abc10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 May 2026 12:02:27 +0200 Subject: [PATCH 1/3] docs: document Deno.test() timeout option Adds a "Timeouts" section to the testing fundamentals page covering the per-test `timeout` option from denoland/deno#33815. --- runtime/fundamentals/testing.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index 8acadf0ac..f93dd75b9 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -677,6 +677,30 @@ Deno.test({ }); ``` +## Timeouts + +You can set a maximum duration for individual tests using the `timeout` option. +If a test exceeds its deadline it is marked as failed. Both asynchronous hangs +(a promise that never resolves) and synchronous hot loops (`while (true) {}`) +are caught. + +```ts +Deno.test({ + name: "completes within deadline", + timeout: 5000, // 5 seconds + async fn() { + const response = await fetch("https://example.com"); + await response.body?.cancel(); + }, +}); +``` + +If a test times out the next test in the same file still runs normally. +Sanitizers are skipped for the timed-out test since a forcibly terminated test +will naturally have leaked resources or operations. + +Setting `timeout` to `0` or omitting it means the test runs without a deadline. + ## Snapshot testing The [Deno Standard Library](/runtime/reference/std/) includes a From 72fdf411f283685a5ebc0fc61445bec5c4721cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 20 May 2026 15:13:48 +0200 Subject: [PATCH 2/3] docs: move Timeouts section above Test Hooks --- runtime/fundamentals/testing.md | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index f93dd75b9..64e08cc49 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -118,6 +118,30 @@ Deno.test("database operations", async (t) => { }); ``` +## Timeouts + +You can set a maximum duration for individual tests using the `timeout` option. +If a test exceeds its deadline it is marked as failed. Both asynchronous hangs +(a promise that never resolves) and synchronous hot loops (`while (true) {}`) +are caught. + +```ts +Deno.test({ + name: "completes within deadline", + timeout: 5000, // 5 seconds + async fn() { + const response = await fetch("https://example.com"); + await response.body?.cancel(); + }, +}); +``` + +If a test times out the next test in the same file still runs normally. +Sanitizers are skipped for the timed-out test since a forcibly terminated test +will naturally have leaked resources or operations. + +Setting `timeout` to `0` or omitting it means the test runs without a deadline. + ## Test Hooks Deno provides test hooks that allow you to run setup and teardown code before @@ -677,30 +701,6 @@ Deno.test({ }); ``` -## Timeouts - -You can set a maximum duration for individual tests using the `timeout` option. -If a test exceeds its deadline it is marked as failed. Both asynchronous hangs -(a promise that never resolves) and synchronous hot loops (`while (true) {}`) -are caught. - -```ts -Deno.test({ - name: "completes within deadline", - timeout: 5000, // 5 seconds - async fn() { - const response = await fetch("https://example.com"); - await response.body?.cancel(); - }, -}); -``` - -If a test times out the next test in the same file still runs normally. -Sanitizers are skipped for the timed-out test since a forcibly terminated test -will naturally have leaked resources or operations. - -Setting `timeout` to `0` or omitting it means the test runs without a deadline. - ## Snapshot testing The [Deno Standard Library](/runtime/reference/std/) includes a From 2f3aebc010a89299d4754de69b4f9438a403e066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 20 May 2026 15:17:44 +0200 Subject: [PATCH 3/3] docs: drop sanitizer note from Timeouts section --- runtime/fundamentals/testing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index 64e08cc49..2799aa64f 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -137,8 +137,6 @@ Deno.test({ ``` If a test times out the next test in the same file still runs normally. -Sanitizers are skipped for the timed-out test since a forcibly terminated test -will naturally have leaked resources or operations. Setting `timeout` to `0` or omitting it means the test runs without a deadline.