diff --git a/source/test.ts b/source/test.ts index 70eebdc..f21b0f1 100644 --- a/source/test.ts +++ b/source/test.ts @@ -28,6 +28,16 @@ export class TestContext { ); } + /** Assert that the value is false. */ + false(actual: boolean, title?: string): void { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare + if (actual === false) { + return; + } + + throw new AssertionError("Failed false assertion", actual, false, title); + } + /** Assert that the value is true. */ true(actual: boolean, title?: string): void { // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare diff --git a/tests/assertions.ts b/tests/assertions.ts index b3558aa..cc96b0d 100644 --- a/tests/assertions.ts +++ b/tests/assertions.ts @@ -7,6 +7,11 @@ await setup("Assertions", async (group) => { test.equals("A string!", "A string!", "string"); }); + group.test("false", async (test) => { + test.false(1 < 0, "logic"); + test.false(new Date() instanceof String, "instanceof"); + }); + group.test("true", async (test) => { test.true(1 > 0, "logic"); test.true(new Date() instanceof Date, "instanceof");