{"id":27691,"library":"deno-test","title":"deno-test","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install deno-test","lang":"bash","label":"npm"},{"cmd":"yarn add deno-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add deno-test","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Module resolution for Deno-style imports (jsr:, @std/*)","package":"@deno/loader","optional":false},{"reason":"Provides Deno.test and t.step shim for Node.js","package":"@deno/shim-deno-test","optional":false}],"imports":[{"note":"Deno.test is globally injected via @deno/shim-deno-test when file is loaded by CLI.","wrong":"import { Deno } from 'deno-test';","symbol":"Deno.test","correct":"// no import needed; Deno.test is global when using deno-test CLI"},{"note":"Use jsr: specifiers or import map; raw URL imports not supported.","wrong":"import { assertEquals } from 'https://deno.land/std/assert/mod.ts';","symbol":"assertEquals","correct":"import { assertEquals } from '@std/assert';"},{"note":"t.step must be awaited; maps to node:test subtests.","wrong":"t.step('sub', () => {}); // missing await","symbol":"t.step","correct":"Deno.test('name', async (t) => { await t.step('sub', () => {}); });"},{"note":"The hooks module is internal; do not import directly.","wrong":"import 'deno-test/register-deno-hooks.mjs';","symbol":"register-deno-hooks","correct":"// not imported; CLI handles automatically"}],"quickstart":{"code":"// Create a test file: math_test.ts\nimport { assertEquals } from '@std/assert';\n\nDeno.test('add', () => {\n  assertEquals(1 + 1, 2);\n});\n\n// Run with npx deno-test (no extra config)\n// Requires deno.json with import map referencing @std/assert\n// > npx deno-test","lang":"typescript","description":"Demonstrates writing a Deno-style test and running it on Node.js via npx."},"warnings":[{"fix":"Upgrade Node.js to 23.6.0 or later.","message":"Node.js >= 23.6.0 required (uses module.registerHooks())","severity":"breaking","affected_versions":"<=1.0.2"},{"fix":"Place import map in deno.json at project root.","message":"Import maps must be in deno.json; other config files are not supported","severity":"gotcha","affected_versions":"<=1.0.2"},{"fix":"Use jsr:@scope/pkg or add to import map in deno.json.","message":"Raw URL imports (https://deno.land/...) are not resolved; use jsr: or import map","severity":"gotcha","affected_versions":"<=1.0.2"},{"fix":"Always use async (t) => callback with await t.step().","message":"Deno.test steps must be async callbacks; sync callbacks may cause unexpected results","severity":"deprecated","affected_versions":"<=1.0.2"},{"fix":"No fix needed; be aware of discovery scope.","message":"Files in node_modules, .git, vendor are skipped automatically","severity":"gotcha","affected_versions":"<=1.0.2"},{"fix":"Polyfill missing Deno APIs separately or avoid them in tests.","message":"Supports only Deno.test and t.step; other Deno globals (e.g., Deno.readFile) are not available","severity":"breaking","affected_versions":"<=1.0.2"},{"fix":"Use --reporter flag of node:test if needed.","message":"Output uses node:test reporter; may differ from Deno's test output formatting","severity":"gotcha","affected_versions":"<=1.0.2"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade to Node.js >= 23.6.0","cause":"Node.js version < 23.6.0; module.registerHooks() not available","error":"Cannot find module 'register-deno-hooks.mjs' required by 'deno-test'"},{"fix":"Run file with npx deno-test [file] instead of node","cause":"Test file not loaded by deno-test CLI; trying to import directly in Node.js","error":"TypeError: Deno.test is not a function"},{"fix":"Ensure deno.json exists at project root with correct 'imports'","cause":"Missing or misconfigured import map in deno.json","error":"Error: Unsupported file extension .ts for import map resolution"},{"fix":"Use await t.step() inside async (t) => {}","cause":"t.step called without await in async callback","error":"Test steps not executed: step callback must be async"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}