-
Notifications
You must be signed in to change notification settings - Fork 16
Testing guidance
Frank Kim edited this page Jun 20, 2020
·
1 revision
✅ This guide assumes that the reader has their local machine setup with all required tools and is able to run all parts of the project locally
- Go into the directory for api (learn>packages>api>tests)
- Run yarn coverage, this will generate a report showing which module is low in coverage. It even points out the lines which are not covered for easy reference. We typically aim to have 80-70 percent coverage for modules.
- Create a PR for any low coverage module, if none are present
- Create a branch called ‘feature/test name’, checkout the branch and start coding
✅ Make sure to look into other tests previously done for reference
- TestClient is used to start-stop the in-memory database, also has functionality for resetting the DB after each test
- Use the random input to create the module needed to test with random fields. Make sure to understand the relationship between the module and its parents for testing purposes as the parents also need to be created.
- Create a test for all functions under the module (create, update, delete…)
- Test both happy and negative flows, negative example: create two objects with same ID
- Create the test.ts file
- Add the mutations in TestClient
- Add the query in TestClient
- If needed make sure the module has been imported
- Add the mutations to mutations/index.ts
- Create your mutations .gql file
- Create your queries .gql file
- Add the query to queries/index.ts
- Describe each test separately to allow for clarity
- Each test should test one thing and one thing only
This project is built and maintained by the community of Code Mentoring.
Built by the people, for the people
Packages
Issues/PRs
API
Testing
Contributing