Nestjs Testing logo

Nestjs Testing

Organization
nestjs
nestjs-testing

Unit, service and end-to-end tests for a NestJS application with @nestjs/testing - Test.createTestingModule, mocking and overriding providers and global guards, Supertest against the real app, signing test users in, SSE, test databases, Vitest in ESM projects (Jest in CommonJS ones). Use when writing, running or fixing tests in a NestJS application.

Overview

Publishernestjs
Repositoryagent-skills
Skill namenestjs-testing
Stars
176
Forks
5
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by nestjs on GitHub. Read the source before you install it.

Installation

Install the Nestjs Testing AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-testing
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nestjs/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/plugins/nestjs/skills/nestjs-testing .claude/skills/nestjs-testing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Nestjs Testing in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Nestjs Testing on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Nestjs Testing is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Testing a NestJS app

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.

Pick the level

WhatHowSpeed
A policy, a pure function, a mappernew NotePolicy(fakeQuotas): no Nest at allms
A service's rulesTest.createTestingModule({ providers: [NotesService, { provide: NotesRepository, useValue: { findById: vi.fn() } }] })ms
A service with the real policiesthe above plus imports: [AuthorizationModule.forRoot()] and a stub AuthenticationContextms
A route as clients see itimports: [AppModule], Supertest on app.getHttpServer(), a fresh database100s of ms

Runner

  • Projects from 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".
  • CommonJS projects use Jest (jest.fn()). Follow the project's package.json.

Rules that save debugging time

  • The testing app doesn't run 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.
  • Module options are read when the module file is imported. Set env variables (database path, secrets) in the Vitest config's test.env, or import AppModule dynamically after setting them.
  • A global guard registered with 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.
  • Sign users in cheaply. Override 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.
  • One database per test file. Vitest runs files in parallel: a shared SQLite file or schema makes them interfere. Create a temporary file (or schema) per file, apply the migrations, delete it afterwards.
  • No ports, no leftovers. 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.
  • Time-dependent code (reminders, expiry, rate windows): inject a clock or the delay, rather than sleeping in tests.
  • Test what the client sees in e2e tests: status codes, bodies, headers. Assert the exact status the contract names (expect(201) on a create, expect(200) on a sign-in), which also catches @Post()'s default 201.

When tests fail to start

  • 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.
  • The app works but the test module doesn't: something is registered in main.ts only (see above), or env variables are read before the test sets them.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Nestjs Testing AI skill do?

Unit, service and end-to-end tests for a NestJS application with @nestjs/testing - Test.createTestingModule, mocking and overriding providers and global guards, Supertest against the real app, signing test users in, SSE, test databases, Vitest in ESM projects (Jest in CommonJS ones). Use when writing, running or fixing tests in a NestJS application.

Why use Nestjs Testing on TypingMind?

Because you install it once and use it with any model. Nestjs Testing is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Nestjs Testing in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-testing. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Nestjs Testing?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Nestjs Testing?

As many as you like. As long as a model supports skills, you can use Nestjs Testing with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Nestjs Testing AI skill free?

Yes. It is published on GitHub by nestjs under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇