node-test-runner

Writes and runs unit tests for astro-blocks using the built-in Node.js test runner.

28|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/NauelG/astro-blocks --skill node-test-runner-nauelg
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: node-test-runner
Source: https://github.com/NauelG/astro-blocks/tree/main/.agents/skills/node-test-runner
Command: npx skills add https://github.com/NauelG/astro-blocks --skill node-test-runner-nauelg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent unit tests for astro-blocks requires knowing the project's specific conventions: node:test imports, dist/ imports, temp-directory isolation, and env-var save/restore. This Skill encodes those patterns so tests follow the same structure as the existing 16 test files without trial and error. ## Core Features & Use Cases - Standardized Test Structure: Enforces the node:test and node:assert/strict import pattern with flat and async test syntax used across the tests/ directory. - Isolation Patterns: Provides the withTempProject helper and env-var save/restore idiom for tests that read or write data/ files. - Targeted Test Execution: Documents commands for running the full suite, a single file, a regex-matched subset, or watch mode. - Use Case: When adding a new API handler to astro-blocks, use this Skill to scaffold a tests/*.test.js file that imports from ../dist/, isolates state with withTempProject, and runs via node --test. ## Quick Start Write a unit test for the new astro-blocks handler following the node:test conventions and run it with node --test.

Frequently Asked Questions about node-test-runner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests with the Node.js built-in test runner?▼

Import test from node:test and assert from node:assert/strict, then define tests with test('name', () => { ... }) or async callbacks. Run them with node --test tests/*.test.js, no jest or vitest required.

How to run a single test file or subset with node --test?▼

Run one file with node --test tests/<file>.test.js, or filter by name using node --test --test-name-pattern="<regex>" tests/*.test.js. Node 22 and later also support watch mode via node --test --watch.

Why do astro-blocks tests fail when importing from src instead of dist?▼

Tests import compiled output from ../dist/, so running node --test without a prior build fails to resolve modules. Always run npm test, which executes npm run build first, or build manually before testing.

How do I isolate tests that read or write data files in Node.js?▼

Use the withTempProject pattern: create a temp directory with fs.mkdtemp, set ASTRO_BLOCKS_PROJECT_ROOT to it, run the test, then restore the env var and delete the directory in a finally block. Check prev === undefined to decide between delete and restore.

Does node:test support async assertions for rejected promises?▼

Yes, use await assert.rejects(async () => someAsyncFn(), { message: /pattern/ }) from node:assert/strict to verify a promise rejects with an expected error. This works natively without extra assertion libraries.