...
Additionally, follow the Testing Patterns from Test Driven Development: By Example, which are:
Child Test. Start with testing small pieces of your code. Then integrate them into larger tests as needed.
...
After creating the unit tests, create integration tests with full calls to the API server (no mocks).
Each test must be enclosed by a test case, covering a single endpoint (based on the routes). Test files must be named like:
endpoint.tests.js
, and reside within the pathsrc/tests/endpointName
.To avoid test failures, each test suite must include within a mechanism to isolate and refresh the database being used to test.
Tests are build using Jest framework with Mocha and Chai assertion libraries.
Every user to run the tests must be created prior to executing a single test.
All API tests must be executed before deploying to a new an environment (beta.litefarm.org and litefarm.org) as part of a CI pipeline.
...
Every new React Component must include tests using Enzyme and Jest, mocking any calls to the API.
Tests must cover: the visibility of a component, the load of nested components, the props that must be passed, any state changes based on user interaction and expected calls to downstream code must be mocked.
Tests must be within the same path where the component code is. Tests file must be named like:
originalCode.tests.js
.All tests must be executed on every commit locally and as part of CI/CD piepline.
Integration tests to the UI
Integrations tests to the UI must include testing the overall functionality of litefarm.org website.
Tests of the UI must be done using Cypress framework.
The user to run the tests must be created prior to running the tests.
The data to perform the tests shall be based on fake scenarios, using data on the
/fixtures
path.All integrations tests must be executed before deploying to a new environment (beta.litefarm.org and litefarm.org) as part of a CI pipeline
References
8 principles of better unit testing
Why good developers write bad tests