@denofill/testing

0.2.0 • Public • Published

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.

// If you set DENOFILL_TEST=1 in Node.js, this will run the tests. Otherwise,
// this will be a no-op.
import * as Deno from "@denofill/testing";
import assert from "node:assert";

Deno.test("1 + 2 = 3", () => {
  assert.equal(1 + 2, 3);
});
<script>
  // You can also manually do this in DevTools and reload the page.
  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 };

Package Sidebar

Install

npm i @denofill/testing

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

40.2 kB

Total Files

41

Last publish

Collaborators

  • jcbhmr