Quality Assurance
Testing Methodology
Overview
At Formbricks, we maintain a rigorous testing strategy to ensure high-quality code and reliable functionality. Our testing approach is standardized and integrated into our development workflow.
Testing Structure
Unit Testing with Vitest
We use Vitest as our primary testing framework. All unit tests follow these conventions:
-
File Location and Naming
- Test files are co-located with the source files they test
- Test files use the
.test.ts
extension (e.g.,utils.test.ts
testsutils.ts
)
-
Test Organization
-
Coverage Requirements
- Minimum 85% code coverage requirement (WIP π·ββοΈ)
- Coverage is tracked using V8 provider
- Coverage reports include:
- Text summaries
- HTML reports
- LCOV reports
End-to-End Testing with Playwright
E2E tests are located in apps/web/playwright/
and focus on critical user workflows.
Testing Setup
Configuration
Our Vitest configuration (vite.config.ts
) includes:
Test Utilities
Common test utilities are available in vitestSetup.ts
:
- Mock implementations for commonly used functions
- Test lifecycle hooks (beforeEach, afterEach)
- Validation test helpers
Best Practices
-
Test Independence
-
Mocking
- Use Vitestβs built-in mocking utilities
- Mock external dependencies and services
- Example:
-
Assertions
- Write clear, specific assertions
- Test both success and error cases
- Example:
Quality Assurance Process
-
Continuous Integration
- Automated test suite execution on pull requests
- Coverage reports generation
- Test results reporting
-
New Features
- Must include corresponding unit tests
- Must maintain or improve coverage metrics
- Must include relevant E2E tests for user-facing features
Was this page helpful?