name: test
description: Run tests for the Ghostfolio project - smart detection of affected projects, specific test files, or full suite
disable-model-invocation: true
allowed-tools: Bash, Read, Grep, Glob
argument-hint: "[all|api|client|common|ui|affected|]"
Ghostfolio Smart Test Runner
Run tests intelligently based on what changed or what's specified.
Project Context
- Test framework: Jest 30.2.0 with ts-jest
- Monorepo: NX workspace with 4 projects (api, client, common, ui)
- 30 spec files across the workspace
- Tests load
.env.examplevia dotenv-cli (no running DB/Redis needed)
Commands
Based on $ARGUMENTS:
No argument or affected
Run tests only for NX projects affected by current changes:
cd /home/james-allen/Projects/ghostfolio && npx nx affected --target=test --base=main --head=HEAD --parallel=4
If no changes detected, report that and suggest running all.
all
Run the full test suite:
cd /home/james-allen/Projects/ghostfolio && npm test
api
Run API (backend) tests only:
cd /home/james-allen/Projects/ghostfolio && npm run test:api
client
Run Angular client tests:
cd /home/james-allen/Projects/ghostfolio && npx nx test client
common
Run shared library tests:
cd /home/james-allen/Projects/ghostfolio && npm run test:common
ui
Run UI library tests:
cd /home/james-allen/Projects/ghostfolio && npm run test:ui
File pattern (anything else)
Find and run matching spec files:
- Use Glob to find
**/*$ARGUMENTS*.spec.tsfiles - If exactly one match, run it directly:
cd /home/james-allen/Projects/ghostfolio && npx jest --config apps/api/jest.config.ts --testPathPattern="<matched-file>" - If multiple matches, show them and ask which to run
On Failure
When tests fail:
- Read the failing test file
- Read the source file under test
- Analyze the failure message
- Suggest a fix with specific code changes
- Offer to apply the fix
Test File Locations
- API portfolio calculator tests:
apps/api/src/app/portfolio/calculator/roai/*.spec.ts(21 files) - API other tests:
apps/api/src/app/**/*.spec.ts - Common lib tests:
libs/common/src/lib/**/*.spec.ts - UI lib tests:
libs/ui/src/lib/**/*.spec.ts