mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-18 05:19:29 +08:00
28 lines
824 B
TypeScript
28 lines
824 B
TypeScript
// @exit: 1
|
|
// t.test subtests: awaited subtests report indented under their parent,
|
|
// a failing subtest fails the parent (both count as fail), and the
|
|
// failing section lists the subtest's own error.
|
|
import assert from "node:assert";
|
|
import { test } from "node:test";
|
|
|
|
test("parent with passing subtests", async (t) => {
|
|
await t.test("sub one", () => {});
|
|
await t.test("sub two", () => {
|
|
assert.strictEqual("a" + "b", "ab");
|
|
});
|
|
});
|
|
|
|
test("parent with a failing subtest", async (t) => {
|
|
await t.test("good sub", () => {});
|
|
await t.test("bad sub", () => {
|
|
throw new Error("subtest failure");
|
|
});
|
|
});
|
|
|
|
test("subtests with directives", async (t) => {
|
|
await t.test("skipped sub", { skip: true }, () => {
|
|
throw new Error("never runs");
|
|
});
|
|
await t.test("todo sub", { todo: true }, () => {});
|
|
});
|