char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somport test extension typescript96879c9

main
2.3 KiB69 linesraw
1import { test, type TestContext, type TestOptions } from "avril:test";
2
3const options: TestOptions = {
4  name: "options",
5  timeout: Infinity,
6  only: false,
7  ignore: false,
8  async fn(t) {
9    const name: string = t.name;
10    const passed: boolean = await t.step("nested", async (child) => {
11      const result: boolean = await child.step({ name: "ignored", ignore: true });
12    });
13    await t.step({
14      name: "options",
15      fn: (child) => {
16        const name: string = child.name;
17      },
18    });
19  },
20};
21const registered: void = test(options);
22test("named", (t) => {
23  const context: TestContext = t;
24});
25test.only(options);
26test.only("named", (t) => {
27  const name: string = t.name;
28});
29test.ignore(options);
30test.ignore("ignored");
31test.ignore("ignored", (t) => {
32  const name: string = t.name;
33});
34const only: typeof test.only = test.only;
35only("detached", () => {});
36
37// @ts-expect-error The name form requires a callback.
38test("missing");
39// @ts-expect-error The focused name form requires a callback.
40test.only("missing");
41// @ts-expect-error Registration needs a name or options.
42test();
43// @ts-expect-error Callbacks cannot return arbitrary promises.
44test("wrong result", async () => 42);
45// @ts-expect-error Options retain their numeric timeout.
46test({ name: "wrong timeout", timeout: "100" });
47// @ts-expect-error Registration is not asynchronous.
48const promise: Promise<void> = test("synchronous registration", () => {});
49// @ts-expect-error The internal runner is not a public export.
50import { runTests } from "avril:test";
51// @ts-expect-error Private extension modules are absent from the public graph.
52import { op_test_event } from "ext:core/ops";
53
54test("steps", async (t) => {
55  // @ts-expect-error Context names are readonly.
56  t.name = "changed";
57  // @ts-expect-error The name form requires a callback.
58  t.step("missing");
59  // @ts-expect-error Steps do not accept test timeouts.
60  t.step({ name: "timeout", timeout: 10 });
61  // @ts-expect-error Steps cannot be focused.
62  t.step({ name: "focused", only: true });
63  // @ts-expect-error Steps resolve a boolean, not a string.
64  const result: string = await t.step("result", () => {});
65  await t.step("nested", (child) => {
66    // @ts-expect-error Nested step contexts have the same readonly name.
67    child.name = "changed";
68  });
69});