machiatto
This module provides a Mocha-like interface with support for full async functions across the board. Hopefully it just works.
Pending work
Module is in prelim state - YMMV.
- unit tests
- full integration tests
- full documentation
Install
import * as Machiatto from 'https://deno.land/x/machiatto'
Usage
It's mostly just like Mocha.
Run / name your tests just as you would with deno test
, as this uses
Deno.test
under the hood.
The module provides the following exports:
describe
creates a new nested suite of testsit
defines a new test in the current suitebefore
runs once before any tests in the suitebeforeEach
runs before each test in the suiteafter
runs once after all tests in the suiteafterEach
runs after each test in the suiterun
actually executes the tests
All functions passed can be async and will be executed in defined order, with the exception of tests - tests are run in parallel.
export { expect } from "https://deno.land/x/expect@v0.2.6/mod.ts";
import { beforeEach, describe, it, run } from "../test.ts";
import { clone } from "./date.ts";
describe("date.ts", () => {
beforeEach((ctx) => {
ctx.date = new Date("04/09/2021");
});
describe("#clone", () => {
beforeEach((ctx) => {
ctx.cloned = clone(ctx.date);
});
it("returns a date from the exact same time", (ctx) => {
expect(ctx.date.getTime()).toEqual(ctx.cloned.getTime());
});
it("returns a different date object", (ctx) => {
expect(ctx.date).not.toBe(ctx.cloned);
});
});
});
await run();