deno-testing
FreeNo executable scriptsNot checkedDeno testing with Deno.test and std/testing. Covers unit tests, async tests, mocking, snapshots, and BDD-style testing. USE WHEN: user mentions "deno test"…
by claude-dev-suite★ 51 GitHub starsAbout this skill
Deno Testing Core Knowledge
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:denofor comprehensive documentation.
Full Reference: See advanced.md for FakeTime, BDD Style, Snapshots, HTTP Testing, Integration Tests, Test Context, Custom Assertions, and Permissions Testing.
When NOT to Use This Skill
- Node.js Projects - Use
vitestorjestfor Node.js - Browser-Only Code - Use Playwright for browser automation
- Python Projects - Use
pytestfor Python - Java Projects - Use
junitfor Java - Non-Deno TypeScript - Use
vitestfor standard TypeScript
Basic Testing
Unit Tests
// math.ts
export function add(a: number, b: number): number {
return a + b;
}
export function divide(a: number, b: number): number {
if (b === 0) {
throw new Error("Division by zero");
}
return a / b;
}
// math_test.ts
import { assertEquals, assertThrows } from "https://deno.land/[email protected]/assert/mod.ts";
import { add, divide } from "./math.ts";
Deno.test("add positive numbers", () => {
assertEquals(add(2, 3), 5);
});
Deno.test("divide by zero throws", () => {
assertThrows(
() => divide(10, 0),
Error,
"Division by zero"
);
});
Running Tests
# Run all tests
deno test
# Run specific file
deno test math_test.ts
# Run tests matching pattern
deno test --filter "add"
# Allow permissions
deno test --allow-read --allow-net
# Watch mode
deno test --watch
# Coverage
deno test --coverage=cov_profile
deno coverage cov_profile --html
Assertions
import {
assertEquals,
assertNotEquals,
assertStrictEquals,
assertExists,
assertInstanceOf,
assertArrayIncludes,
assertStringIncludes,
assertMatch,
assertThrows,
assertRejects,
assert,
} from "https://deno.land/[email protected]/assert/mod.ts";
Deno.test("assertions examples", () => {
assertEquals({ a: 1 }, { a: 1 });
assertNotEquals({ a: 1 }, { a: 2 });
assertStrictEquals(obj, obj); // Reference equality
assertExists("value"); // Not null/undefined
assertInstanceOf(new Date(), Date);
assertArrayIncludes([1, 2, 3], [2, 3]);
assertStringIncludes("hello world", "world");
assertMatch("hello123", /\d+/);
assert(true);
});
Deno.test("error assertions", async () => {
assertThrows(() => { throw new Error("oops"); }, Error, "oops");
await assertRejects(async () => { throw new Error("async error"); }, Error);
});
Test Organization
Test Steps
Deno.test("user workflow", async (t) => {
let userId: string;
await t.step("create user", async () => {
const response = await fetch("http://localhost:8000/users", {
method: "POST",
body: JSON.stringify({ name: "Alice" }),
});
const user = await response.json();
userId = user.id;
assertEquals(user.name, "Alice");
});
await t.step("get user", async () => {
const response = await fetch(`http://localhost:8000/users/${userId}`);
const user = await response.json();
assertEquals(user.id, userId);
});
});
Test Options
Deno.test({
name: "test with options",
permissions: { read: true, net: true },
fn: async () => {
const data = await Deno.readTextFile("./data.txt");
assertEquals(data.length > 0, true);
},
});
Deno.test({
name: "ignored test",
ignore: Deno.build.os === "windows",
fn: () => { /* Skipped on Windows */ },
});
Deno.test({
name: "test with sanitizers disabled",
sanitizeResources: false,
sanitizeOps: false,
fn: async () => { /* Test that might leak resources */ },
});
Async Testing
Deno.test("async test", async () => {
const result = await asyncOperation();
assertEquals(result, "expected");
});
Deno.test("timeout handling", async () => {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
try {
const response = await fetch("http://example.com", {
signal: controller.signal,
});
assertEquals(response.ok, true);
} finally {
clearTimeout(timeout);
}
});
Mocking
Spy Functions
import { spy, assertSpyCalls, assertSpyCall } from "https://deno.land/[email protected]/testing/mock.ts";
Deno.test("spy example", () => {
const func = spy((x: number) => x * 2);
assertEquals(func(2), 4);
assertEquals(func(3), 6);
assertSpyCalls(func, 2);
assertSpyCall(func, 0, { args: [2], returned: 4 });
});
Deno.test("spy on object method", () => {
const obj = {
greet(name: string) { return `Hello, ${name}!`; },
};
const greetSpy = spy(obj, "greet");
assertEquals(obj.greet("Alice"), "Hello, Alice!");
assertSpyCalls(greetSpy, 1);
greetSpy.restore();
});
Stub Functions
import { stub, returnsNext } from "https://deno.land/[email protected]/testing/mock.ts";
Deno.test("stub example", () => {
const obj = { getValue: () => Math.random() };
Install deno-testing in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
ReadGrepGlobWriteEditBashBundled files
FAQ
What does the deno-testing skill do?
Deno testing with Deno.test and std/testing. Covers unit tests, async tests, mocking, snapshots, and BDD-style testing. USE WHEN: user mentions "deno test", "deno testing", asks about "Deno.test", "assertSnapshot", "FakeTime", "spy", "stub", "BDD deno" DO NOT USE FOR: Node.js projects - use `vitest` or `jest`; Browser-only code - use Playwright; Python - use `pytest`; Java - use `junit`; Non-Deno TypeScript - use `vitest`
How do I install the deno-testing skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the deno-testing skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic