Esta guía explica cómo ejecutar los diferentes tipos de tests en el proyecto CronosMatic.
- Cantidad: 93 tests
- Tipos: Unit tests, Feature tests, API tests
- Framework: PHPUnit
- Ubicación:
tests/directory
- Cantidad: 34 tests
- Tipos: Component tests, Page tests
- Framework: Vitest + Testing Library
- Ubicación:
resources/js/__tests__/directory
- Cantidad: 11 tests
- Tipos: Integration tests, User journey tests
- Framework: Cypress
- Ubicación:
cypress/e2e/directory
# Backend (PHP/Laravel)
composer test
# o
npm run test:backend
# Frontend (React/Vitest)
npm run test:run
# o
npm run test:frontend
# E2E (Cypress)
npm run test:e2e# Opción 1: Comando npm secuencial
npm run test:all
# Opción 2: Script shell con mejor formato
./run-all-tests.shnpm run test # Modo watch (desarrollo)
npm run test:ui # Interfaz gráfica de Vitest
npm run test:coverage # Con reporte de coberturanpm run test:e2e:open # Abre Cypress en modo interactivonpm run lint # ESLint con auto-fix
npm run format # Prettier formatting
npm run format:check # Verificar formato
npm run types # TypeScript type checkingCuando todos los tests pasan exitosamente, deberías ver:
✅ Backend Tests (93 tests) - PASÓ
✅ Frontend Tests (34 tests) - PASÓ
✅ E2E Tests (11 tests) - PASÓ
🎉 Total: 138 tests
- Configuración:
phpunit.xml - Base de datos: SQLite en memoria para tests
- Factories:
database/factories/ - Seeders para tests:
database/seeders/
- Configuración:
vitest.config.ts - Setup:
resources/js/__tests__/setup.ts - Mocks: Incluye mocks para Inertia.js y componentes UI
- Configuración:
cypress.config.ts - Base URL:
http://localhost:8000 - Soporte:
cypress/support/
# Limpiar caché y configuración
php artisan config:clear
php artisan cache:clear
php artisan test# Asegúrate de que el servidor esté corriendo
php artisan serve # Puerto 8000
npm run dev # Puerto 5173# Reinstalar dependencias
npm ci
npm run test:run- Prerequisitos: Asegúrate de que los servidores estén corriendo para los tests E2E
- Orden de Ejecución: Backend → Frontend → E2E (para máxima confiabilidad)
- CI/CD: Todos los tests deben pasar antes de hacer merge a main
- Cobertura: Se recomienda mantener > 80% de cobertura en componentes críticos
- Backend:
tests/Feature/Http/Controllers/ProductControllerTest.php - Frontend:
resources/js/__tests__/pages/Products/Show.test.tsx - E2E:
cypress/e2e/products.cy.ts
- ✅ HU1.2: Vista de detalle de producto
- ✅ HU1.5: Visualización de stock
- ✅ Manejo de errores 404
- ✅ Integración con API endpoints
- ✅ Responsividad y UX