supertest-nestjs

Write e2e API tests for NestJS applications using Supertest.

Updated Jan 26, 2023
One-click install
npx skills add https://github.com/avvale/aurora-back --skill supertest-nestjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supertest-nestjs
Source: https://github.com/avvale/aurora-back/tree/main/.claude/skills/supertest-nestjs
Command: npx skills add https://github.com/avvale/aurora-back --skill supertest-nestjs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of writing robust end-to-end (e2e) tests for NestJS applications, ensuring your API endpoints function correctly and reliably.

Core Features & Use Cases

  • Comprehensive Testing: Covers REST API endpoints, GraphQL mutations/queries, and authentication flows.
  • Best Practices: Provides clear guidelines and code examples for effective testing strategies.
  • Use Case: When developing a new user registration endpoint in your NestJS app, use this Skill to write e2e tests that verify successful registration, handle invalid input, and confirm proper authentication.

Quick Start

Use the supertest-nestjs skill to write a basic GET request test for the '/users' endpoint, expecting a 200 status code.

Frequently Asked Questions about supertest-nestjs

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

FAQPage Schema
How do I write e2e API tests for a NestJS application?

Writing e2e API tests for a NestJS application involves using the Supertest library to simulate HTTP requests, assert response status codes, and verify endpoint behaviors against your routing modules comprehensively.

Can I test GraphQL operations using Supertest in NestJS?

Yes, you can test GraphQL operations using Supertest in NestJS. The approach covers sending GraphQL queries and mutations to your endpoints and asserting the response payloads for accurate data retrieval.

What is the best way to test authentication mechanisms like JWT in NestJS e2e tests?

The best way to test authentication mechanisms like JWT in NestJS e2e tests is to employ specific patterns for generating tokens, attaching them as headers in Supertest requests, and validating protected route access.

How do I handle database seeding when e2e testing a NestJS API?

Handling database seeding when e2e testing a NestJS API involves employing strategies for custom test databases and populating them with initial data to ensure comprehensive and isolated test coverage.

Does this testing approach support file uploads and error handling scenarios?

Yes, this testing approach supports file uploads and error handling scenarios. It provides patterns to simulate multipart form data and assert proper error responses for invalid inputs or failures.