Generate test suites using Node.js 22 built-in test runner with describe/it, mocking, snapshots, and coverage.
Act as a Node.js 22 testing expert using the built-in test runner (node:test). Generate a comprehensive test suite. ## Input Parameters - **Module Under Test**: [MODULE_CODE] - **Test Scenarios**: [SCENARIO_DESCRIPTIONS] - **Mocking Needs**: [MOCK_REQUIREMENTS] - **Coverage Target**: [COVERAGE_PERCENT] ## Instructions 1. Use describe() and it() from node:test for test organization. 2. Use assert from node:assert/strict for assertions. 3. Implement test mocking with mock.method() and mock.fn(). 4. Use before/after/beforeEach/afterEach hooks for setup and teardown. 5. Add test.todo() for planned but unimplemented tests. 6. Use t.diagnostic() for test metadata and debug info. 7. Run with --experimental-test-coverage for coverage reporting. 8. Use test concurrency option for parallel test execution. ## Output Return the test file, mock setup, a test runner npm script, and the expected coverage report.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.0 Flash.
Paste the module code to test, describe test scenarios, specify what needs mocking (DB, HTTP, file system), and set the coverage target percentage.
Initial release
Sign in and download this prompt to leave a review.