Skip to main content
The project includes comprehensive testing and code quality tools for both backend and frontend code.

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

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.
1

Install Dependencies

2

Configure Vitest

vite.config.ts
3

Write Tests

tests/components/AppHeader.test.ts
4

Add Script

package.json

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 the RefreshDatabase 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:
1

Install Husky

2

Configure Pre-commit

.husky/pre-commit
3

Configure Lint-Staged

package.json

Testing Best Practices

Each test should verify one behavior or scenario.
Use RefreshDatabase to ensure tests don’t affect each other.

Code Coverage

Generate code coverage reports:
This ensures at least 80% of your code is covered by tests.

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