Testing With Deno - Framework
shadowtime2000

shadowtime2000 @shadowtime2000

About: If you are looking at this you probably wonder who I am; teenage open source maintainer

Joined:
Jul 12, 2020

Testing With Deno - Framework

Publish Date: Nov 6 '20
13 0

Testing With Deno

In this multipart tutorial I will show how to test with Deno.

The Built-in Deno Testing

Deno has it's own built in testing framework

// some_file_test.ts
Deno.test({
    name: "my test",
    fn: (): void => {
        // Do some testing here
    }
});
Enter fullscreen mode Exit fullscreen mode

And you can run these tests with

$ deno test
Enter fullscreen mode Exit fullscreen mode

But What Is Wrong With This?

Well, it is hard to have structure in your tests, like frameworks such as Jest and Mocha allow.

Rhum - The Deno Testing Framework

Rhum is a Deno testing framework created by the deno-drash REST microframework team. Let's take a look at how you use it.

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

Rhum.testPlan("some_file_test.ts", () => {
    Rhum.testSuite("MyFunction", () => {
        Rhum.testCase("does stuff", () => {
            // Assert some stuff
        });
    });
});
Enter fullscreen mode Exit fullscreen mode

Benefits

The Rhum testing framework allows you to have more complex organization of unit tests.

I will soon by posting a tutorial on assertion libraries.

Comments 0 total

    Add comment