How to reuse helper function in Angular testing?

In my unit test (written with a protractor), I need to write functions to be used across multiple tests across multiple files (and only unit tests).

How can I create these functions?

The best solution is to declare the functions in one file to be included in the test files that I need, but I don't know how to do this without creating global variables or global functions.

+3


source to share


1 answer


If you follow the Page Object pattern , you won't be in this situation. All the features you need will be tied to page pages, you will have great separation of concerns, and any changes to your element selection logic will feel like a breeze. You can also think of page objects as global libraries available in your tests.

See also how you can apply the template with protractor

:



+2


source







All Articles