2022-12-22 13:00:03 +00:00
|
|
|
import {setup} from "../source/index.js";
|
|
|
|
|
2022-12-27 19:16:54 +00:00
|
|
|
await import("./assertions.js");
|
2024-01-27 12:00:48 +00:00
|
|
|
await import("./example.js");
|
2022-12-27 19:16:54 +00:00
|
|
|
|
2022-12-22 13:00:03 +00:00
|
|
|
async function add(a: number, b: number): Promise<number> {
|
|
|
|
await new Promise<void>((resolve) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve();
|
|
|
|
}, Math.random() * 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function subtract(a: number, b: number): Promise<number> {
|
|
|
|
await new Promise<void>((resolve) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve();
|
|
|
|
}, Math.random() * 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
return a - b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setup("add", async (group) => {
|
|
|
|
group.test("add(1, 1) = 2", async (test) => {
|
|
|
|
test.equals(await add(1, 1), 2);
|
|
|
|
});
|
|
|
|
|
|
|
|
group.skip("add(1, 1) = 3", async (test) => {
|
|
|
|
test.equals(await add(1, 1), 3);
|
|
|
|
});
|
|
|
|
|
|
|
|
group.test("add(1, 1) = 4", async (test) => {
|
|
|
|
test.equals(await add(1, 1), 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-12-27 14:25:04 +00:00
|
|
|
void setup(
|
|
|
|
"subtract",
|
|
|
|
async (group) => {
|
|
|
|
group.beforeAll(async () => {
|
|
|
|
console.log("subtract beforeAll hook");
|
|
|
|
});
|
|
|
|
|
|
|
|
group.afterAll(async () => {
|
|
|
|
console.log("subtract afterAll hook");
|
|
|
|
});
|
|
|
|
|
|
|
|
group.test("subtract(1, 1) = 0", async (test) => {
|
|
|
|
test.equals(await subtract(1, 1), 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
group.skip("subtract(1, 1) = 1", async (test) => {
|
|
|
|
test.equals(await subtract(1, 1), 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
group.test("subtract(1, 1) = 2", async (test) => {
|
|
|
|
test.equals(await subtract(1, 1), 2, "extra title");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
parallel: false,
|
|
|
|
},
|
|
|
|
);
|