🧪 Moduł testing
use "testing";
Funkcje
| Funkcja | Opis |
describe(name, fn) | Grupa testów |
test(name, fn) | Pojedynczy test |
expect(value) | Asercja |
testSummary() | Podsumowanie testów |
Metody expect()
| Metoda | Opis |
.toBe(val) | Równość |
.toEqual(val) | Głęboka równość |
.toBeTrue() | Czy true? |
.toBeFalse() | Czy false? |
.toBeNull() | Czy null? |
.toContain(val) | Czy zawiera? |
.toHaveLength(n) | Długość |
.toBeGreaterThan(n) | Większe niż |
.toBeLessThan(n) | Mniejsze niż |
.toThrow() | Czy rzuca błąd? |
Przykład
use "testing";
describe("Math functions", fn() {
test("add works", fn() {
expect(2 + 2).toBe(4);
});
test("list contains", fn() {
expect([1,2,3]).toContain(2);
});
});
testSummary();