How to Eliminate Duplication in Tests
Problem
Often, before running the next Testplane test, certain preparatory work needs to be done, such as:
- clearing all cookies;
- cleaning localStorage;
- initializing some test variable.
Similarly, after completing the main checks in a Testplane test, you may always want to check for errors in the client code, the triggering of required metrics, etc.
Solution: testplane-global-hook
To avoid repeating these actions each time in your tests, add the testplane-global-hook plugin and describe them in the plugin settings as functions for the beforeEach
and afterEach
hooks.
Learn more about how to add and configure the plugin in the plugin documentation.
Keywords
- testplane-global-hook