mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
node:test changes, matching Node 24.22:
- When a test's { timeout } elapses, its subtests that are still running
are cancelled, the innermost first. Each reports its duration so far and
fails with "test did not finish before its parent and was cancelled",
before the parent's result.
- A cancelled subtest's body keeps running unobserved: when it settles it
reports nothing and leaves the runner's state alone. Before, it reported
its result after the run's summary.
The timeout-subtests fixture compares the results, counts and failing
section with Node, plain and with SCRIPTC_SAN=1.
24 lines
772 B
TypeScript
24 lines
772 B
TypeScript
// @exit: 1
|
|
// A test that times out cancels its subtests that are still running, the
|
|
// innermost first, with "test did not finish before its parent and was
|
|
// cancelled". Subtests that finished keep their results, and the
|
|
// cancelled bodies report nothing when they settle later.
|
|
import { test } from "node:test";
|
|
|
|
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
|
test("parent", { timeout: 40 }, async (t) => {
|
|
await t.test("finished first", () => {});
|
|
await t.test("running", async (t) => {
|
|
await t.test("inner done", () => {});
|
|
await t.test("inner running", async () => {
|
|
await sleep(300);
|
|
throw new Error("never reported");
|
|
});
|
|
});
|
|
});
|
|
|
|
test("next", async () => {
|
|
await sleep(400);
|
|
});
|