How we test our code
We don’t just want our code to work; we want it to be “accurate.” Since we are an analytics platform, a small bug in a math formula can cause big problems for our users.
The three levels of testing
1. Backend Logic Tests (Pytest)
We test the “Math” separately from the website.
- Location:
plugzero_api/tests/ - What we test: Functions in
processors.pylikecalculate_basic_stats. We send them a fake table and make sure the average and mode are exactly right. - How to run:
pytestfrom the backend directory.
2. API Endpoint Tests
We test to make sure the “Doors” to our system work correctly.
- We check that a user can login, create a team, and upload a file.
- We also check “Negative Tests”—making sure a user cannot see a project that belongs to a different team.
3. Frontend Component Tests (Vitest)
We test our UI components to make sure they look and behave correctly.
- Does the chart show a “No data” message when the payload is empty?
- Does the “Add Team” button disable itself while the request is loading?
How to add a test
Write the test file
Put your test in a file named something.test.ts (for frontend) or test_something.py (for backend).
Use “Mocks”
Don’t talk to the real database or the real AI during a test. Use a “Mock” or a fake version instead. This makes the tests fast and reliable.
Run before you push
Always run the test suite before you create a Pull Request on GitHub. Our system will run them again automatically once you push.
Coverage Goal: We focus on 100% coverage for the Analysis Engine. Other parts of the site (like marketing pages) don’t need such strict testing.