Before Your First Test
This documentation is still being updated. Some of its contents still related to using the old testing framework: Detox.
You've just been given a task to automate, with acceptance criteria and error cases to consider, and aren't sure where to begin...
Have no fear, this document will walk you through a standard test from start to finish, and coupled with the rest of our documentation, should hopefully set you on the path to writing comfortably and independently.
1. Ensure Your Environment is Prepared Correctly
Double check that you've configured your environment correctly by ensuring you've followed everything within Getting Started.
2. Validate Your Acceptance Criteria and Testing Paths
Test tickets can come in different forms, and each case in writing within a ticket doesn't necessarily dictate that an individual test is required to match the acceptance criteria. Think logically about the best approach to the task you've been given:
- Does what you have to test have a stable setup state?
- Can I eliminate multiple checks within the one test reliably without introducing flake? Eg. I'm testing a login flow, so I could reasonably test the happy path in one test case, and split the error cases into suitably smaller test cases, perhaps even putting all text validation into one case rather than an individual case for each.
- Are there error cases that haven't been considered that I can also cover?
- What can I skip via the API from repeated actions within the test to avoid additional points of failure?
- Do I need to mock any data, or are there outside factors that will effect the pass rate of my test?
Scrutinise the task you've been given. No harm can come from additional coverage.
3. Check that Your Test Case isn't Already Covered Elsewhere
The suite already contains coverage of various areas, and chances are that what you are working on has already been handled previously, but is outdated or no longer functional. Look through our existing files within e2e/tests
and ensure that what you're trying to achieve isn't already handled elsewhere.
If it is, check that the functionality is up to date both through visual inspection of the file, and by running the test with yarn e2e:run:<platform>:<brand> <relative-path-to-test>
. Refer to Running Tests if you're unfamiliar with the required process.
If your task exists in an outdated or dysfunctional form, update the file that it already lives within, otherwise create an appropriately named file within an appropriate folder in e2e/tests
(kebab-case is the preferred case for all E2E files).
4. Start Writing Your Test
- Follow the test steps from the original test case
- Ensure all steps are covered including the negative scenarios
- Do not create any duplicate code. If its used across multiple tests create a flow that can be called within the tests.
- Run your tests often. The more you run them, the more likely you'll run into flake that you can address.
Refer to Writing Tests for instructions on how to create the base flow yaml file which will launch the app.
Below is an example yaml config for a test for this Jira ticket (https://jira.production.corporate.ladbrokes.cloud/browse/QA-263)