Deno Testing

Deno has a built-in test runner that can be used for testing Typescript and Javascript code.

Once, you have installed deno, just run deno test in the command line and it will execute all the test files you have.

We can run specific files by referencing them after the command.

deno test tests/employee.test.ts

Writing Deno Test

To define a deno test, we need to call Deno.test with the name and function that needs to be tested.

There are two ways to define:

Compact Form

// Simple name and function, compact form, but not configurable
Deno.test("adding two numbers", () => {
  const x = 10 + 20;
  assertEquals(x, 30);
});

Long Form

// Full fledged test definition, longer form, but configurable
Deno.test({
  name: "addition of two numbers",
  fn: () => {
    const x = 10 + 20;
    assertEquals(x, 30);
  },
});

Deno Testing

To know more on deno testing please refer deno.land