/nestjs:nestjs-testingfrom NestJS
Provides recipes for unit, service, and e2e testing in NestJS using @nestjs/testing, Vitest, or Jest. Covers mocking providers, overriding guards, Supertest, test databases, and signing test users in.
Ships in NestJS. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Docs: https://docs.nestjs.com/fundamentals/testing.md. Recipes, each run with Vitest on the scaffold's config: references/testing.md.
Scope first. When the task says how to test, do that. When it says nothing, cover the behaviour you changed with focused tests (a unit test for a policy or a service rule, one e2e test per new route and its main error) rather than broad e2e suites, and verify the rest by running the app.
| What | How | Speed |
|---|---|---|
| A policy, a pure function, a mapper | new NotePolicy(fakeQuotas): no Nest at all | ms |
| A service's rules | Test.createTestingModule({ providers: [NotesService, { provide: NotesRepository, useValue: { findById: vi.fn() } }] }) | ms |
| A service with the real policies | the above plus imports: [AuthorizationModule.forRoot()] and a stub AuthenticationContext | ms |
| A route as clients see it | imports: [AppModule], Supertest on app.getHttpServer(), a fresh database | 100s of ms |
nest new are ESM with Vitest (globals: true): npm test runs src/**/*.spec.ts, npm run test:e2e runs test/**/*.e2e-spec.ts. Mocks are vi.fn()/vi.spyOn(); relative imports end in .js. One file: npx vitest run src/notes/notes.service.spec.ts; one test: add -t "name".jest.fn()). Follow the project's package.json.main.ts. Pipes, filters, prefixes and versioning set there are missing in tests: put them in one configureApp(app) that main.ts and the tests both call, or register them as APP_PIPE/APP_FILTER providers.test.env, or import AppModule dynamically after setting them.useClass can't be replaced in tests. Neither .overrideGuard(ThrottlerGuard) nor .overrideProvider(ThrottlerGuard) touches { provide: APP_GUARD, useClass: ThrottlerGuard } (checked). Register it as ThrottlerGuard plus { provide: APP_GUARD, useExisting: ThrottlerGuard }, then .overrideProvider(ThrottlerGuard).useValue({ canActivate: () => true }) works. Or keep the guard and give tests a limit they won't reach.PasswordHasher with new PasswordHasher({ logN: 10 }) (the default costs ~0.3 s and 128 MiB per hash); mint a bearer token with app.get(TokenService).issue(user.id); run service code as a user with app.get(AuthenticationContext).run({ user }, fn). Keep one test that signs in through the real route.await app.init() and request(app.getHttpServer()) need no port; afterAll(() => app.close()) closes connections and timers. Leave no server or watcher running when you finish.expect(201) on a create, expect(200) on a sign-in), which also catches @Post()'s default 201.Nest can't resolve dependencies of NotesService (?) in a unit test: the testing module lacks a provider. Add a useValue stub for it, or useMocker(() => ({})) for everything missing.main.ts only (see above), or env variables are read before the test sets them.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub z-ey3eiei/nestjs.skill --plugin nestjs6 skills in this plugin
/nestjsNestJS, the TypeScript framework for Node.js backends. How to start a project non-interactively with the Nest CLI, the project layout and module system, where the current docs are, and the mistakes agents make in Nest apps that still pass their tests. Use when creating or extending a NestJS application./nestjs-authSign-in, sessions, bearer tokens, API keys and permissions in a NestJS application with the first-party @nestjs/authentication and @nestjs/authorization packages - timing-safe password checks, a global guard with @Public(), policies with @Can(), and what to do when a task fixes the JWT secret or token format. Use when adding or changing authentication or authorization in a NestJS application./nestjs-dataDatabases in a NestJS application with the first-party @nestjs/drizzle and @nestjs/typeorm integrations - registering the database, injecting it into services, schemas or entities, migrations, transactions, and writes that stay correct under concurrent requests. Use when adding or changing persistence in a NestJS application./nestjs-featureAdd or change HTTP endpoints in a NestJS application - modules, controllers and services, request validation (Zod or another Standard Schema library with @Body({ schema }), or class-validator DTOs), status codes, error response bodies, request IDs, versioning and Server-Sent Events. Use when adding or changing endpoints in a NestJS application./nestjs-productionProduction setup for a NestJS application with first-party packages - configuration and env validation (@nestjs/config), structured logs, observability with NestJS Observe (@nestjs/observe), health and readiness checks (@nestjs/terminus), rate limiting (@nestjs/throttler), OpenAPI (@nestjs/swagger), graceful shutdown and deployment behind a load balancer. Use when preparing a NestJS application for production, or adding any of these to one.2 plugins ship this exact skill · first indexed Nov 20, 2026
Other plugins' skills for the same job