gen-test

gen-test is a command for Claude Code from hmake98/nestjs-starter. It costs 0 tokens per session (513 once invoked), scanned A, original, MIT.

A command that creates Jest unit-test files for a specified source file, following the project's existing test structure and mocking conventions.

In plain words
What is it for?
Use it to generate tests for services and other classes in a TypeScript project that uses Jest.
Why use it?
It reduces the manual work of finding the right test layout, checking every method and error path, and setting up dependency mocks.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/hmake98/nestjs-starter/gen-test
Clone the repo
git clone --depth 1 https://github.com/hmake98/nestjs-starter

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gen-test

README.md
[![agentmods](https://agentmods.dev/badge/commands/hmake98/nestjs-starter/gen-test.svg)](https://agentmods.dev/commands/hmake98/nestjs-starter/gen-test)
Your own site
<a href="https://agentmods.dev/commands/hmake98/nestjs-starter/gen-test"><img src="https://agentmods.dev/badge/commands/hmake98/nestjs-starter/gen-test.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 513 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00513
Opus 5 $0.00000 $0.00257
Sonnet 5 $0.00000 $0.00103
Haiku 4.5 $0.00000 $0.00051

Measured 4d ago against content hash 2e3f915e790f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gen-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/gen-test.md · 41 lines

What it actually says

Generate unit tests for: $ARGUMENTS

Read these files first to understand the exact testing patterns used in this project:

  • test/modules/user.service.spec.ts — service test pattern
  • test/modules/auth.service.spec.ts — service test with external mocks (argon2, jwt)
  • test/common/cache.service.spec.ts — common service test pattern
  • test/common/database.service.spec.ts — class mocking pattern with jest.mock()
  • test/jest.json — Jest config (clearMocks + restoreMocks are global — do NOT add jest.clearAllMocks() in beforeEach)

Then read the actual file being tested to understand all methods, branches, and error paths.

Rules to follow:

Structure

  • File goes in test/ mirroring the src/ path (e.g. src/modules/post/services/post.service.tstest/modules/post.service.spec.ts)
  • Top-level describe('<ClassName>') block
  • Nested describe('<methodName>') for each public method
  • it('should be defined') smoke test

Mocking

  • Mock all injected dependencies as plain objects with jest.fn() for every method
  • Do NOT use jest.createMockFromModule or @golevelup/ts-jest
  • For module-level mocks (argon2, ioredis, prisma client) use jest.mock('module-name') at the top of the file
  • ConfigService mock: implement getOrThrow with a Record<string, string> map covering all keys the service accesses

Test cases — for every method generate:

  1. Happy path — returns expected value
  2. Not-found / guard clause — throws HttpException with correct HttpStatus
  3. Dependency failure — mock rejects, assert the error propagates or is handled
  4. Edge cases specific to the method's branching logic

Assertions

  • Use await expect(promise).resolves.toEqual(...) and await expect(promise).rejects.toThrow(HttpException)
  • After write operations assert the repository method was called with expect(mock.method).toHaveBeenCalledWith(...)
  • Use expect.objectContaining({}) when only part of the call args matters

Do NOT

  • Call jest.clearAllMocks() — handled globally by jest config
  • Import jest — it is a global
  • Add unnecessary async to tests that don't await
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 41 lines · 0 tokens per session scan A 2e3f915e790f

Subscribe to this mod's changes

gen-test is a command published in the GitHub repository hmake98/nestjs-starter (61 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 513 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.