Skip to content

Unit Testing Standard

Unit tests provide the fastest reliable feedback on business logic, validation, authorization, state transitions, and error handling.

Repository familyRequired runnerSupporting libraries
nexa-web / ReactVitestTesting Library, user-event, jsdom
nexa-backend / Node.js TypeScriptVitestVitest mocks/fakes and repository test utilities
FastAPI / PythonPytestpytest-cov, fixtures, parametrization

Jest is not an approved Nexa baseline for nexa-web or nexa-backend.

  • Unit tests run on every pull request.
  • Tests are deterministic and do not require live cloud services.
  • External SDKs, clocks, random sources, queues, databases, and networks are isolated through adapters, controlled fakes, or test containers at the appropriate layer.
  • A defect fix includes a regression test where technically feasible.
  • A failing unit test blocks merge.
  • Results are exported in a CI-readable format and coverage is exported as LCOV or Cobertura/XML as required by SonarQube.

Coverage supports review and risk assessment; it is not a target to game. New and changed code should carry meaningful tests for critical paths and negative behavior. SonarQube consumes the coverage report generated by Vitest or Pytest; SonarQube does not execute the tests.

Vitest and Pytest are the source-CI merge gates. Browser/E2E, API/contract, integration, Playwright, and Allure evidence belongs after deployment to a lower environment and does not replace unit testing.

Over-mocking implementation detail, sleeping for timing, sharing mutable fixtures, asserting only happy paths, and making live platform calls create slow and unreliable suites.