deno-test

raw JSON →
1.0.2 verified Sat May 09 auth: no javascript

Run Deno-style tests (Deno.test, t.step) on Node.js without rewriting test files. v1.0.2 requires Node.js >=23.6.0 for its sync module hooks. Resolution uses @deno/loader to handle jsr:, @std/*, and import maps. Outputs results via node:test runner. Ideal for checking Node.js compatibility of Deno-first packages.

error Cannot find module 'register-deno-hooks.mjs' required by 'deno-test'
cause Node.js version < 23.6.0; module.registerHooks() not available
fix
Upgrade to Node.js >= 23.6.0
error TypeError: Deno.test is not a function
cause Test file not loaded by deno-test CLI; trying to import directly in Node.js
fix
Run file with npx deno-test [file] instead of node
error Error: Unsupported file extension .ts for import map resolution
cause Missing or misconfigured import map in deno.json
fix
Ensure deno.json exists at project root with correct 'imports'
error Test steps not executed: step callback must be async
cause t.step called without await in async callback
fix
Use await t.step() inside async (t) => {}
breaking Node.js >= 23.6.0 required (uses module.registerHooks())
fix Upgrade Node.js to 23.6.0 or later.
gotcha Import maps must be in deno.json; other config files are not supported
fix Place import map in deno.json at project root.
gotcha Raw URL imports (https://deno.land/...) are not resolved; use jsr: or import map
fix Use jsr:@scope/pkg or add to import map in deno.json.
deprecated Deno.test steps must be async callbacks; sync callbacks may cause unexpected results
fix Always use async (t) => callback with await t.step().
gotcha Files in node_modules, .git, vendor are skipped automatically
fix No fix needed; be aware of discovery scope.
breaking Supports only Deno.test and t.step; other Deno globals (e.g., Deno.readFile) are not available
fix Polyfill missing Deno APIs separately or avoid them in tests.
gotcha Output uses node:test reporter; may differ from Deno's test output formatting
fix Use --reporter flag of node:test if needed.
npm install deno-test
yarn add deno-test
pnpm add deno-test

Demonstrates writing a Deno-style test and running it on Node.js via npx.

// Create a test file: math_test.ts
import { assertEquals } from '@std/assert';

Deno.test('add', () => {
  assertEquals(1 + 1, 2);
});

// Run with npx deno-test (no extra config)
// Requires deno.json with import map referencing @std/assert
// > npx deno-test