Skip to content

describe ​

Signaturedescribe(name: string, callback: () => void): void

describe(name, callback) opens a suite and runs callback immediately, so the tests and hooks registered inside it belong to that suite. No test runs during registration: tests run after the program has registered everything, in the order they were written, and a nested suite runs where it appears.

A test's full name is its path through the suites, joined with >, as in discount > from 100 on > is ten percent.

When an assertion fails while a suite's callback is registering, the suite is reported as failed and none of its tests run.

tyrus
import { describe, it, expect } from "tyrus:test";

const discount = (total: i32): i32 => {
    if (total >= 100) {
        return total / 10;
    }
    return 0;
};

describe("discount", () => {
    it("is zero below 100", () => {
        expect(discount(99)).toBe(0);
    });

    describe("from 100 on", () => {
        it("is ten percent", () => {
            expect(discount(250)).toBe(25);
        });
    });
});