67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import {setup} from "../source/index.js";
|
|
|
|
await import("./assertions.js");
|
|
await import("./example.js");
|
|
|
|
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;
|
|
}
|
|
|
|
await 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);
|
|
});
|
|
});
|
|
|
|
await 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,
|
|
},
|
|
);
|