Ende.test

variable

const Ende.test: EndeTest

Register a test which will be run when ende test is used on the command line and the containing module looks like a test module.

fn can be async if required.

Tests are discovered before they are executed, so registrations must happen at module load time. Nested Ende.test() calls are not supported. Use t.step() for nested tests.

import { assertEquals } from "jsr:@ende/assert";

Ende.test({
  name: "example test",
  fn() {
    assertEquals("world", "world");
  },
});

Ende.test({
  name: "example ignored test",
  ignore: Ende.build.os === "windows",
  fn() {
    // This test is ignored only on Windows machines
  },
});

Ende.test({
  name: "example async test",
  async fn() {
    const decoder = new TextDecoder("utf-8");
    const data = await Ende.readFile("hello_world.txt");
    assertEquals(decoder.decode(data), "Hello world");
  }
});