We've documented few important best practices to help you with e2e tests:
Your test cases shouldn't be responsible for verifying more than a single and focused functionality. For example, in a note taking app's 'listing and filtering notes' module, one of the test case could be 'pressing next loads next batch of notes'. In that test we can perform following steps:
- Open the 'notes listing' page. When notes are loaded, keep the
idof the last note in variable
- Hit 'Next' and verify that the first note from next batch of notes has
id > lastNoteId.
No more verification in this particular test. This way test cases look focused, to the point, easily manageable and follow good coding practices.
Every test case should be able to successfully run on it's own with no dependence on any other test. No test should share test state with other test. For instance, if you've set a custom timeout in some test, don't forget to reset it in the same test. Don't leave it on other tests to first reset any custom timeouts. Another example, if you open a url and do some tests on a page, don't expect another test to resume the testing because there is no defined order in which multiple tests run in a build. Write focused test and finish a particular test case within it's own single test.