Testing Overview
The Money monorepo emphasizes code quality and reliability. While comprehensive test coverage is still being developed, this guide outlines testing best practices and available testing approaches.Available Testing Commands
Type Checking
TypeScript serves as the first line of defense against bugs:- Runs
tsc --noEmitto check for TypeScript errors - Validates type correctness without emitting files
- Catches type mismatches, missing properties, and more
Linting
ESLint ensures code quality and consistency:- Code style and formatting issues
- Potential bugs and anti-patterns
- React and Next.js best practices
- Accessibility issues
Format Checking
Prettier maintains consistent code formatting:Testing Strategy
Type Safety First
Use TypeScript’s type system to catch errors at compile time:Ensure all type errors are resolved before committing code.
Lint for Quality
Run ESLint to catch potential issues:The configuration enforces
--max-warnings 0 for web, docs, and cashgap apps.Manual Testing
Test functionality manually in the browser:Verify:
- User flows work as expected
- Forms validate correctly
- Authentication and authorization work
- Database operations succeed
Testing Best Practices
Code Review Checklist
Before submitting code for review:- All TypeScript errors resolved (
pnpm check-types) - No linting errors or warnings (
pnpm lint) - Code is properly formatted (
pnpm format) - Production build succeeds (
pnpm build) - Tested functionality manually in browser
- Verified database operations (if applicable)
- Checked for console errors or warnings
Type Safety Guidelines
Use strict typesany types
Use specific types or unknown when type is truly unknown:
Future Testing Additions
The following testing capabilities are planned for future implementation:Unit Testing
Planned framework: Jest or Vitest- Test individual functions and components
- Mock dependencies and external services
- Fast, isolated test execution
Integration Testing
Planned tools: Playwright or Cypress- Test user workflows end-to-end
- Verify database operations
- Test API endpoints
- Validate authentication flows
Component Testing
Planned framework: React Testing Library- Test React components in isolation
- Verify component behavior and rendering
- Test user interactions
- Ensure accessibility
Pre-commit Hooks
Consider setting up Git hooks to run checks automatically:Using Husky
Pre-commit Hook Example
CI/CD Testing
Example GitHub Actions workflow:Debugging
Chrome DevTools
For browser-based debugging:-
Start the dev server:
- Open Chrome DevTools (F12)
- Use the Sources panel to set breakpoints
- Use the Console to inspect variables and execute code
VS Code Debugger
Create.vscode/launch.json:
Node.js Debugger
For server-side debugging:Common Issues
Type Errors in Third-Party Packages
If you encounter type errors from dependencies:ESLint Errors
To disable specific rules (use sparingly):Build Succeeds but Runtime Errors
This usually indicates:- Missing environment variables
- Database connection issues
- External service failures
Next Steps
Contributing Guidelines
Learn how to contribute to the project
Code Style
Follow the project’s code style
Pull Requests
Submit your changes
Building
Build for production