- Dynamically adding components to the DOM is asynchronous
- Code being tested might call Apex, which is asynchronous
Promises only available in SFDC "Supported" browsers. In Communities, you have to assume users will use un-supported browsers. For this reason, tests can be written using callbacks instead of Promises by passing callbacks to each assertion.
This means Promises cannot be used in client code. They could still be used in test code since you control the browsers used to invoke tests but that means the tests cannot be used to check your code in all browsers that users might use.
Tests are made up of the following parts:
- TestSomeComponent.app - which extends...
- greased_TestCommon.app - which contains...
- greased_TestBase.cmp
Most of the behaviours come from the TestBase component and it can be re-used inside other applications if that's useful.
The TestCommon app exists to provide:
- An app to extend/inherit from for tests
- SLDS style for tests
- Parameter parsing features (TODO) for tests
- Simplified initialisation and access to the driver object for tests
The last item is the most useful for tests because it keeps them simple. Under the covers, there is some complexity which addresses LockerService rules around inheritance and composition but tests don't see this.
If you want to use the TestBase component, you will need to learn how the TestCommon app initialises the TestBase. The comments in those fns should provide a good example.