Tests
Deno have its own Test library, so there is no need to use external tools like Jest or others.
Tests structures
Simple test
Deno.test('', () => {});Test steps
Deno also supports test steps, which allow you to break down tests into smaller, manageable parts.
Deno.test("database operations", async (t) => {
using db = await openDatabase();
await t.step("insert user", async () => {
// Insert user logic
});
await t.step("insert book", async () => {
// Insert book logic
});
});Assertions
Deno provides a function assertEqual and others for asserting expected values.
But it also provides an assert function like Jest expect.
Running tests
Run deno test without a file name or directory name, this subcommand will automatically find and execute all tests in the current directory (recursively).
Last updated