For most changes to the Desktop App, we should consider writing an automated test to ensure that the change or fix is maintained in the codebase. Depending on the nature of the change, we can write a unit test or an E2E (end-to-end, or integration) test.
We use the jest
test runner to run unit tests in the Desktop App.
You can run the following command to run the tests:
npm run test:unit
Unit tests are usually written for parts of the common
and main
modules, and usually cover individual functions or classes.
We should endaevor to write our code for easy testibility, and any new features or bug fixes should likely have an associated unit test if possible.
An example unit test PR can be found here.
In order to ensure that most of the app is covered, we try to maintain 70% coverage of the common
and main
modules.
You can view a coverage map by running this command:
npm run test:coverage
We use a combination of two technologies to facilitate E2E testing in the Desktop App:
To build the app and run the E2E tests, you can run the following command:
npm run test:e2e
You can also run this command to build the tests without rebuilding the app with this command:
npm run test:e2e:nobuild
E2E tests are usually written to cover parts of the renderer
module and should generally cover complete workflows, such as creating/editing a server.
You will generally need a combination of both Playwright and RobotJS APIs to test most workflows.
An example E2E test PR can be found here.
There are many interactions (ie. things that integrate with the operating system), such as notifications, that cannot be adequately testing using the automation frameworks we have. If this is the case, we will generally create a script to test in Rainforest, our crowd-sourced QA platform to perform these tests manually.