run-test
$
npx mdskill add mx-space/core/run-testExecute project tests using pnpm, glob, and Bash.
- Runs unit and end-to-end tests via pnpm with pattern matching.
- Depends on Bash, Glob, and Read tools to locate and execute tests.
- Executes commands directly without invoking the LLM model.
- Outputs test results directly to the terminal or log stream.
SKILL.md
.github/skills/run-testView on GitHub ↗
--- name: run-test description: Run tests. Supports running all tests, single file, or pattern-matched tests. argument-hint: [file-path|pattern] disable-model-invocation: true allowed-tools: Bash(pnpm test*), Bash(cd *), Read, Glob --- # Run Tests Run project tests. Arguments: `$ARGUMENTS` ## Test Commands ### Run All Tests ```bash pnpm test ``` ### Run Single Test File ```bash # Using relative path (from apps/core directory) pnpm test -- test/src/modules/post/post.controller.e2e-spec.ts # Using filename pattern pnpm test -- --testNamePattern="PostController" ``` ### Watch Mode ```bash pnpm -C apps/core run test:watch ``` ### Run Specific Test Case ```bash # Match test name pnpm test -- --testNamePattern="should create post" ``` ## Test Directory Structure ``` apps/core/test/ ├── src/ │ ├── modules/ # Module tests │ │ ├── post/ │ │ │ ├── post.controller.e2e-spec.ts │ │ │ └── post.e2e-mock.db.ts │ │ ├── user/ │ │ │ ├── user.controller.spec.ts │ │ │ ├── user.controller.e2e-spec.ts │ │ │ └── user.service.spec.ts │ │ └── ... │ ├── utils/ # Utility tests │ ├── processors/ # Processor tests │ └── transformers/ # Transformer tests ├── helper/ # Test helpers ├── mock/ # Mock implementations └── setup-global.ts # Global setup ``` ## Test Types | Suffix | Type | Description | |--------|------|-------------| | `.spec.ts` | Unit test | Test single function or class | | `.e2e-spec.ts` | E2E test | Test complete HTTP request flow | ## Execution Steps 1. Analyze arguments to determine which tests to run 2. If file path specified, verify file exists first 3. Execute appropriate test command 4. Report test results ## Common Issues ### Test Timeout Increase timeout: ```bash pnpm test -- --testTimeout=30000 ``` ### Memory Issues Tests use in-memory database. If memory issues occur: ```bash NODE_OPTIONS="--max-old-space-size=4096" pnpm test ``` ### Run Only Failed Tests ```bash pnpm test -- --reporter=verbose ```
More from mx-space/core
- api-conventionsMX Space API design conventions. Apply when writing controllers, API endpoints, or handling HTTP requests.
- create-e2e-testCreate E2E test file for a specified module. Use when adding end-to-end tests for controllers or unit tests for services and repositories.
- create-moduleCreate a new NestJS module with repository, service, controller, schema, and Drizzle table definition. Use when adding new feature modules, API endpoints, or business domains.
- mx-pg-controller-migrationUse when verifying and porting an mx-core controller (Post/Note/Page/Comment/Category/etc.) after the MongoDB→PostgreSQL cutover, or when its data shape no longer matches what api-client and admin-vue3 expect. Triggers on "校验 controller"、"check controller"、"迁移 controller"、"修复迁移后的接口"、"data missing after PG migration"、"related/category 字段丢了" and similar.
- mx-reviewReview code for MX Space project conventions. Checks NestJS patterns, Drizzle ORM repositories, Zod schemas, API design, etc.
- release-coreUse when releasing mx-core server (apps/core) or @mx-space/api-client package — version bump, changelog, git tag, Docker build, GitHub Release, and Dokploy redeploy. Triggers on "发版", "release a new version", "cut a release", "bump version", "publish api-client".
- zod-patternsMX Space project Zod schema patterns. Apply when creating DTOs, validation schemas, or handling request validation.