Help us improve
Share bugs, ideas, or general feedback.
From mern-ninja
Generates tests for Node.js backend code including Express routes, MongoDB models, and services. Analyzes file types, detects test framework from package.json, includes setup/teardown and edge cases.
npx claudepluginhub 9tykeshav/mern-ninja-marketplace --plugin mern-ninjaHow this skill is triggered — by the user, by Claude, or both
Slash command
/mern-ninja:backend-test-writerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate comprehensive backend tests for MERN stack code. Analyzes file type, detects project conventions, produces tests that actually run.
Generates backend tests (unit, integration, mocks) for existing code. Auto-invokes when user says 'write test for', 'add test', or 'test this'.
Generates test files with happy path, edge case, and error path coverage that run and pass on first try. Detects project's test framework, analyzes target modules, and iterates up to 3 fix cycles before marking failures as skipped.
Generates tests for any file type with automatic framework detection, project convention matching, and type-specific routing (React, Vue, Python, Go, Rust, PHP, E2E).
Share bugs, ideas, or general feedback.
Generate comprehensive backend tests for MERN stack code. Analyzes file type, detects project conventions, produces tests that actually run.
Philosophy: Smart defaults, zero config. Detect everything from project.
Copy and track progress:
Before generating tests, verify setup:
package.json for test framework (Jest/Vitest/Mocha)mongodb-memory-server (needed for integration tests)__tests__/ vs tests/)Stop if: No test framework and user declines setup.
| Pattern | Type | Test Approach |
|---|---|---|
routes/, *.routes.js | Route | Integration (Supertest + real DB) |
controllers/ | Controller | Integration |
services/ | Service | Unit (mocked deps) |
models/, *.model.js | Model | Unit (validation tests) |
middleware/ | Middleware | Unit (mock req/res/next) |
utils/, helpers/ | Utility | Unit (pure functions) |
Override: User can specify --unit or --integration.
Process files sequentially with progress. User can stop anytime.
Each test includes:
Reference: See test-patterns.md for complete code examples.
Generated: X test files
Coverage: Y test cases total
Next: Run `npm test` to verify
| File Type | Imports | DB Setup |
|---|---|---|
| Route | supertest, mongodb-memory-server | Real (in-memory) |
| Service | jest | Mocked |
| Model | mongoose | Mocked |
| Middleware | jest | None |
describe('[Resource] [Method]', () => {
describe('success cases', () => {
it('should [expected behavior]', async () => {});
});
describe('validation errors', () => {
it('should return 400 for [invalid case]', async () => {});
});
describe('edge cases', () => {
it('should handle [edge case]', async () => {});
});
});
package.json"test": "jest")| Mistake | Fix |
|---|---|
| Starting server in tests | Import app, let Supertest handle it |
| No DB cleanup | Add afterEach with deleteMany({}) |
| Testing implementation | Test behavior through HTTP interface |
| Missing async/await | Await async operations |
| Mocking in integration tests | Use real DB for integration |
Load when implementing specific patterns:
| When | Reference |
|---|---|
| Writing any test | test-patterns.md |
| Setting up test infrastructure | test-setup.md |