8. Testing Practices
Maintaining a high-quality codebase is one of our top priorities. To achieve this, we employ a comprehensive suite of testing methodologies and tools. Our aim is to catch issues early, improve software reliability, and speed up the development cycle.
Expectations for Unit and Integration Tests
Unit Tests:
- Every piece of functionality or module should be accompanied by relevant unit tests.
- These tests should focus on smaller parts of the application in isolation (e.g., functions, methods).
- Aim for a coverage of at least 80%. While this isn't a strict rule, it's a guideline to ensure most critical paths are tested.
Integration Tests:
- These tests focus on the interaction between modules and services.
- Any new feature development should ensure that integration points with other systems or services are tested.
- Mock external services when writing integration tests to ensure reliability.
Use of Testing Tools
Backend:
- Mocha & Chai: Our primary tools for writing and asserting tests in the backend.
- Sinon: For mocking and stubbing in tests.
- Supertest: For HTTP assertions, making it easy to test API endpoints.
Frontend:
- Jest: Used for unit testing React components.
- React Testing Library: Assists in rendering components, querying the DOM, and firing events.
- Cypress: For end-to-end testing, ensuring our frontend works cohesively from the user's perspective.
Continuous Deployment Process
Automated Testing: After any code is pushed to our repository, automated tests are run to ensure no regressions have been introduced.
Build & Deployment: Upon successful completion of tests:
- The code is built and any necessary assets are compiled.
- The latest version is deployed to our staging environment for further testing.
Manual QA: Our QA team conducts manual testing on the staging environment to catch any issues that automated tests might have missed.
Production Deployment: Once QA provides the green light, the code is deployed to the production environment. We ensure that there's a rollback strategy in place, allowing us to revert to a previous stable version if any unforeseen issues arise.
We're constantly looking to improve our testing practices. Feedback and suggestions on new tools, methodologies, or improvements to our current practices are always welcome.