Testing With Deno - Framework
shadowtime2000
Posted on November 6, 2020
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
}
});
And you can run these tests with
$ deno test
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
});
});
});
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.
💖 💪 🙅 🚩
shadowtime2000
Posted on November 6, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.