Comprehensive testing strategy using Vitest for unit tests and Playwright for E2E testing with proper test isolation.
test/
├── unit/
│ ├── setup.ts # Vitest configuration
│ └── components/ # Component tests
│ └── ui/
│ └── form/ # Form component tests
└── e2e/
├── auth.setup.ts # Playwright authentication setup
├── db.setup.ts # Database setup for E2E tests
├── app/
│ └── home.spec.ts # Home page functionality
└── swagger/
└── swagger-protection.spec.ts # API documentation protection
Implementation: See test/unit/setup.ts for Vitest configuration and Nuxt composable mocking.
Implementation: See test/unit/components/ for Vue component testing patterns with Vue Test Utils.
Implementation: Composable testing patterns can be implemented for usePostForm and other composables.
Implementation: Pinia store testing can be implemented with createPinia setup.
Configuration: See playwright.config.ts for Playwright setup with multi-browser testing and CI optimization.
Implementation: Authentication flow testing can be implemented for login/register flows.
Implementation: API route testing with authentication scenarios can be implemented.
Implementation: Page Object Model patterns can be implemented for reusable page methods.
Implementation: Test data factory functions can be implemented for generating test data.
Implementation: Database reset and seeding utilities can be implemented for test isolation.
Implementation: Test database isolation can be implemented with beforeAll/afterAll hooks and TEST_DATABASE_URL.
Implementation: Prisma transaction rollback patterns can be implemented for API testing.
- Arrange-Act-Assert pattern for clarity
- Descriptive test names that explain behavior
- Single assertion per test when possible
- Test isolation with proper setup/teardown
- Test behavior, not implementation
- Use data-testid for reliable element selection
- Mock external dependencies
- Test user interactions
- Test critical user journeys
- Use Page Object Model for maintainability
- Test across multiple browsers
- Include accessibility testing
Implementation: Page load time testing can be implemented with Playwright.
Configuration: See vitest.config.ts for test coverage thresholds and provider configuration.
Commands: See package.json scripts for available test commands including unit, E2E, coverage, and debug modes.
Implementation: Debugging patterns can be implemented with vi.fn() mock inspection and component HTML logging.
Commands: Use --debug, --headed flags and trace viewer for E2E test debugging.