Deno testing for anywhere
🧪 [Deno.test()
] and [Deno.bench()
] for anywhere
Installation
You can install this package using npm, pnpm, Yarn, or your other favorite npm
package manager:
npm install @denofill/testing
Usage
You can import this package in Node.js, Deno, and the browser and it will Just
Work™. In Deno, you'll get a passthrough to the native Deno.test()
function,
while in Node.js and the browser you'll get a shim that implements the same API.
import * as Deno from "@denofill/testing";
import assert from "node:assert";
Deno.test("1 + 2 = 3", () => {
assert.equal(1 + 2, 3);
});
<script>
sessionStorage.setItem("denofill_test", "1");
</script>
<script type="module">
import * as Deno from "https://esm.run/@denofill/testing";
import assert from "https://esm.run/@nodefill/assert";
Deno.test("1 + 2 = 3", () => {
assert.equal(1 + 2, 3);
});
</script>
⚠️ Even though it kinda looks like it, the Deno
import is not the real
Deno namespace object! It's only got two functions: Deno.test()
and
Deno.bench()
.
You can also use the shim CLI to run tests and benchmarks using tsx
:
denofilltest
denofillbench
You can combine this Deno
namespace with other @denofill modules to build a custom Deno namespace
import * as Deno1 from "@denofill/testing";
import * as Deno2 from "@denofill/http-server";
const Deno = { ...Deno1, ...Deno2 };