Skip to content

Instantly share code, notes, and snippets.

@crookse
Created November 23, 2019 01:36
Show Gist options
  • Save crookse/a173faf2181110e5dedd0533c6c87dd3 to your computer and use it in GitHub Desktop.
Save crookse/a173faf2181110e5dedd0533c6c87dd3 to your computer and use it in GitHub Desktop.
Deno Unit Testing - imports, test, test(), runTests
import * as testing from "https://deno.land/std/testing/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
function test(nameOfTest: string, testToRun: any): void {
return testing.test({
name: nameOfTest,
fn(): void {
testToRun();
}
});
}
// Define a class we can test
class MyClass {
public hello() {
return "world";
}
}
// Test MyClass
test("MyClass.hello() returns world", () => {
let myClass = new MyClass();
let actual = myClass.hello();
assertEquals(actual, "world");
});
testing.runTests();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment