Testing Stack
PHPUnit
Backend testing framework for unit and feature tests
Laravel Pint
PHP code style fixer based on PHP-CS-Fixer
ESLint
JavaScript/TypeScript linter with Vue support
Prettier
Code formatter for consistent styling
Backend Testing
The project uses PHPUnit for Laravel testing:Configuration
phpunit.xml
Test Structure
Example Feature Test
tests/Feature/DashboardTest.php
Testing Multi-Tenancy
- Tenant Creation
- Tenant Isolation
- Service Tests
tests/Feature/TenantTest.php
Running PHP Tests
Frontend Testing
While the project doesn’t include frontend tests by default, you can add them using Vitest or Cypress.Adding Vitest (Recommended)
Code Quality
PHP Linting with Pint
Laravel Pint automatically fixes code style issues:pint.json
JavaScript Linting with ESLint
ESLint with TypeScript and Vue support:eslint.config.js
Code Formatting with Prettier
.prettierrc
Continuous Integration
Example GitHub Actions workflow:.github/workflows/tests.yml
Test Database
The test suite uses SQLite in-memory database for speed:phpunit.xml
Refresh Database
Use theRefreshDatabase trait to reset the database between tests:
Running All Quality Checks
Run all tests and linters before committing:Pre-commit Hooks
Consider using Husky to run tests automatically:Testing Best Practices
Write Descriptive Test Names
Write Descriptive Test Names
Use Factories
Use Factories
Test One Thing
Test One Thing
Each test should verify one behavior or scenario.
Arrange-Act-Assert
Arrange-Act-Assert
Isolate Tests
Isolate Tests
Use
RefreshDatabase to ensure tests don’t affect each other.Code Coverage
Generate code coverage reports:Performance Testing
For performance testing, consider:- Laravel Telescope: Monitor queries and performance
- Laravel Debugbar: View queries, execution time, memory usage
- Blackfire: Profile PHP applications
Next Steps
Project Structure
Understand the codebase organization
Deployment
Deploy your application to production