Skip to main content
Deno 2 is finally here 🎉️
Learn more

Rhum - A lightweight testing framework for Deno.

Rhum

A lightweight testing framework for Deno.


Table of Contents

Quick Start

// File: app_test.ts

import { Rhum } from "https://deno.land/x/rhum@v1.1.2/mod.ts";

let value = false;

function run() {
  return true;
}

async function close() {
  value = true;
  return value;
}

// 1. Define your test plan (usually the test file's name)
// 2. Define your test suites (usually methods being tested)
// 3. Define your test cases with assertions
Rhum.testPlan("app_test.ts", () => {
  Rhum.testSuite("run()", () => {
    Rhum.testCase("Returns true", () => {
      const result = run();
      Rhum.asserts.assertEquals(true, result);
    });
  });
  Rhum.testSuite("close()", () => {
    Rhum.testCase("Returns true", async () => {
      const result = await close();
      Rhum.asserts.assertEquals(true, result);
    });
  });
});

Rhum.run(); // <-- make sure to include this so that your tests run via `deno test`
$ deno test --allow-env

Compile file:///.deno.test.ts
running 2 tests

app_test.ts
    run()
        Returns true ... ok (4ms)
    close()
        Returns true ... ok (1ms)

Documentation

Full Documentation

Features

  • Descriptive naming for your tests
  • Lightweight
  • Zero dependencies
  • Simple and easy to use
  • Asynchronous support
  • Still uses Deno.test under the hood
  • Skip functionality
  • Hooks

Why Use Rhum?

Rhum allows you to write tests in a very descriptive way – from a code perspective or output perspective.

Rhum is designed to aid your testing efforts – providing many utilities as wrappers around Deno’s existing Deno.test. Rhum is meant to improve the user experience when it comes to writing tests, such as:

  • Readability for test cases
  • Features that aren’t available in Deno yet (hooks)

Rhum takes concepts from the following:

  • Mocha — For how you write tests in Rhum, and the use of hooks
  • Baretest — Being minimalistic

Rhum can be added directly into any project. All you need to do is import Rhum and you are ready to start writing tests or bring your existing tests under Rhum.

Articles

Contributing

Contributors are welcomed!

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

License

By contributing your code, you agree to license your contribution under the MIT License.