create-e2e-test
Create E2E test file for a specified module. Use when adding end-to-end tests for controllers.
Install
mkdir -p .claude/skills/create-e2e-test && curl -L -o skill.zip "https://mcp.directory/api/skills/download/6079" && unzip -o skill.zip -d .claude/skills/create-e2e-test && rm skill.zipInstalls to .claude/skills/create-e2e-test
About this skill
Create E2E Test
Create E2E test file for a module. Module name: $ARGUMENTS
Test File Location
Create file: apps/core/test/src/modules/<module-name>/<module-name>.controller.e2e-spec.ts
E2E Test Template
import { describe, expect, it, afterAll } from 'vitest'
import type { MongooseModel } from '~/shared/types/mongoose.types'
import { createE2EApp } from 'test/helper/create-e2e-app'
import { apiRoutePrefix } from '~/common/decorators/api-controller.decorator'
// Import module under test
import { <Name>Controller } from '~/modules/<name>/<name>.controller'
import { <Name>Service } from '~/modules/<name>/<name>.service'
import { <Name>Model } from '~/modules/<name>/<name>.model'
// Mock data
const mockData = [
{
name: 'Test Item 1',
// ... other fields
},
{
name: 'Test Item 2',
// ... other fields
},
]
describe('<Name>Controller (e2e)', async () => {
let model: MongooseModel<<Name>Model>
const proxy = createE2EApp({
controllers: [<Name>Controller],
providers: [
<Name>Service,
// Add other required providers
],
models: [
<Name>Model,
// Add other required models
],
async pourData(modelMap) {
const { model: _model } = modelMap.get(<Name>Model)!
model = _model
// Insert test data
for (const data of mockData) {
await _model.create(data)
}
},
})
afterAll(async () => {
await model.deleteMany({})
})
describe('GET /<name>s', () => {
it('should return paginated list', async () => {
const res = await proxy.app.inject({
method: 'GET',
url: `${apiRoutePrefix}/<name>s`,
})
expect(res.statusCode).toBe(200)
const json = res.json()
expect(json).toMatchObject({
data: expect.any(Array),
pagination: expect.objectContaining({
total: expect.any(Number),
current_page: expect.any(Number),
}),
})
})
})
describe('GET /<name>s/:id', () => {
it('should return single item by id', async () => {
const item = await model.findOne()
const res = await proxy.app.inject({
method: 'GET',
url: `${apiRoutePrefix}/<name>s/${item!._id}`,
})
expect(res.statusCode).toBe(200)
expect(res.json()).toMatchObject({
name: item!.name,
})
})
it('should return 400 for invalid id', async () => {
const res = await proxy.app.inject({
method: 'GET',
url: `${apiRoutePrefix}/<name>s/invalid-id`,
})
expect(res.statusCode).toBe(400)
})
})
describe('POST /<name>s', () => {
it('should create new item', async () => {
const newItem = {
name: 'New Test Item',
// ... other required fields
}
const res = await proxy.app.inject({
method: 'POST',
url: `${apiRoutePrefix}/<name>s`,
payload: newItem,
})
expect(res.statusCode).toBe(201)
expect(res.json()).toMatchObject({
name: newItem.name,
})
})
it('should return 400 for invalid data', async () => {
const res = await proxy.app.inject({
method: 'POST',
url: `${apiRoutePrefix}/<name>s`,
payload: {}, // Missing required fields
})
expect(res.statusCode).toBe(400)
})
})
describe('PUT /<name>s/:id', () => {
it('should update item', async () => {
const item = await model.findOne()
const updateData = { name: 'Updated Name' }
const res = await proxy.app.inject({
method: 'PUT',
url: `${apiRoutePrefix}/<name>s/${item!._id}`,
payload: updateData,
})
expect(res.statusCode).toBe(200)
expect(res.json()).toMatchObject({
name: updateData.name,
})
})
})
describe('DELETE /<name>s/:id', () => {
it('should delete item', async () => {
const item = await model.create({ name: 'To Delete' })
const res = await proxy.app.inject({
method: 'DELETE',
url: `${apiRoutePrefix}/<name>s/${item._id}`,
})
expect(res.statusCode).toBe(204)
const deleted = await model.findById(item._id)
expect(deleted).toBeNull()
})
})
})
Test Helpers
Database Mock
import { dbHelper } from 'test/helper/db-mock.helper'
// Get model instance
const model = dbHelper.getModel(MyModel)
Redis Mock
import { redisHelper } from 'test/helper/redis-mock.helper'
// Automatically handled in createE2EApp
Auth Mock
In tests, the @Auth() decorator is mocked - all requests are treated as authenticated.
To test unauthenticated scenarios, use the real AuthGuard.
Running Tests
# Run single test file
pnpm test -- test/src/modules/<name>/<name>.controller.e2e-spec.ts
# Run all tests
pnpm test
# Watch mode
pnpm -C apps/core run test:watch
Notes
- Test data is created in
pourDataand cleaned up inafterAll - Use
proxy.app.inject()to send HTTP requests - Responses go through
JSONTransformInterceptor, field names are snake_case - Paginated responses include
dataandpaginationfields - Empty responses return 204 status code
More by mx-space
View all skills by mx-space →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversManage GoLogin browser profiles via AI. Automate with GoLogin, Selenium for software testing, and browser automation stu
Generate stunning images from text with this AI image generator using OpenAI's API and save your creations easily to you
Enhance software testing with Playwright MCP: Fast, reliable browser automation, an innovative alternative to Selenium s
Supercharge browser tasks with Browser MCP—AI-driven, local browser automation for powerful, private testing. Inspired b
Integrate with Gemini CLI for large-scale file analysis, secure code execution, and advanced context control using Googl
LLMS.txt Documentation: Easily fetch and parse llms.txt files to provide instant AI-driven documentation lookup during c
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.