mit einem Klick
test-backend
// Generates backend API integration tests for PwnDoc using Jest and supertest. Tests run against an ephemeral MongoDB instance via ./pwndoc-cli test --backend.
// Generates backend API integration tests for PwnDoc using Jest and supertest. Tests run against an ephemeral MongoDB instance via ./pwndoc-cli test --backend.
Generates Playwright E2E specs for PwnDoc. Tests run against the full stack (frontend + backend + MongoDB) with pre-authenticated browser sessions. Run with ./pwndoc-cli test --frontend-e2e.
Generates frontend unit tests for PwnDoc using Vitest and Vue Test Utils. Handles services (axios mock), components (mount with Quasar), pages (full setup), and Pinia stores. Run with ./pwndoc-cli test --frontend-unit.
Test orchestrator for PwnDoc. Analyzes a feature or the full project to determine test gaps across backend (Jest), frontend unit (Vitest), and frontend E2E (Playwright), then delegates to /test-backend, /test-frontend-unit, and /test-frontend-e2e skills.
| name | test-backend |
| description | Generates backend API integration tests for PwnDoc using Jest and supertest. Tests run against an ephemeral MongoDB instance via ./pwndoc-cli test --backend. |
| context | fork |
| agent | general-purpose |
| allowed-tools | ["Bash","Glob","Grep","Read","Write","Edit"] |
| argument-hint | [feature-name] |
You generate backend API integration tests for PwnDoc. Tests use Jest + supertest against an Express app with an ephemeral MongoDB.
$ARGUMENTS - The feature/resource name to test (e.g., "image", "client", "audit").
If $ARGUMENTS starts with --fix, the format is:
--fix {test-file} "{failure summary}" [--no-run]
Example: --fix backend/tests/image.test.js "expected 201 but received 401" --no-run
In fix mode:
backend/tests/client.test.js--no-run is present, STOP — do not run tests. Otherwise proceed to Step 4 (Run and Fix)Before writing any tests, ALWAYS read:
backend/src/routes/$0.jsbackend/src/models/$0.jsbackend/tests/client.test.jsbackend/tests/index.test.jsbackend/tests/$0.test.jsIf a test file already exists, read it and augment it rather than replacing it.
Write the test to backend/tests/$0.test.js.
Every backend test file exports a function that receives request and app:
/*
State after tests:
{Describe the expected data state after all tests run.
This is critical because tests run sequentially and share the MongoDB.}
*/
module.exports = function(request, app) {
describe('{Feature} Suite Tests', () => {
var userToken = '';
beforeAll(async () => {
var response = await request(app).post('/api/users/token').send({username: 'admin', password: 'Admin123'})
userToken = response.body.datas.token
})
describe('{Feature} CRUD operations', () => {
var item1Id = ""
// Tests here...
})
})
}
All authenticated requests use cookie-based JWT:
var response = await request(app).get('/api/{resource}')
.set('Cookie', [`token=JWT ${userToken}`])
expect(response.status).toBe(XXX) for HTTP status codesexpect(response.body.datas) to access response data (NOTE: datas not data)For each resource, generate tests for:
Admin123 (set by user.test.js which always runs first).After creating the test file, add the require statement in backend/tests/index.test.js in the appropriate position. Respect data dependencies — if your test needs data created by another test, place it after that test.
If $ARGUMENTS contains --no-run, STOP HERE. Do not run tests — the calling orchestrator will handle test execution. Strip --no-run from arguments before processing the feature name in earlier steps.
Otherwise, run tests with:
./pwndoc-cli test --backend
If coverage is requested, use:
./pwndoc-cli test --backend --coverage
If tests fail, read the error output, fix the test file, and re-run. Iterate until all tests pass.
See the template in template-route-test.md for a complete scaffold.