forcedotcom / LightningTestingService

Apache License 2.0
122 stars 35 forks source link

Adding a waitForAura mechanism? #54

Closed KeithClarke closed 4 years ago

KeithClarke commented 6 years ago

Still new to LTS, but finding $T.waitFor pretty annoying in that the condition that you want to expect on ends up in there or ends up being duplicated. Can you comment on the possibility of adding an API to the core Aura libraries of this nature (that is then exposed in LTS):

On top of this, Protractor automatically applies browser.waitForAngular() before every action to wait for all Angular $http and $timeout calls to finish. This allows developers to write the test scripts without much dread "callback hell," for the most part.

so that cleaner tests can be written?

esalman-sfdc commented 6 years ago

Tests written using tools like Protractor/webdriverio etc. run on a dev/build machines and are meant for end-to-end tests by launching a browser and letting you interact with the browser. When you are authoring component tests in LTS, aura the framework is essentially already loaded and ready by the time your test starts running (by virtue of the fact that you kick off a run by going to an aura application).

May be your question is more around testing async code and use of promises. Wondering if you can create some test utils of your own to simplify your test code. For example $T itself is just a static resource file here

KeithClarke commented 6 years ago

Yes my question is about LTS offering more help in handling the asynchronous situations than $T.waitFor. The waitForAngular isn't waiting for Angular to load but for:

wait until Angular has finished rendering and has no outstanding $http or $timeout calls before continuing

So I am wondering about the possibility of a $T.waitForAura() mechanism that holds up the test until Aura has finished all its work, but I assume that would need to hook into the Aura framework somehow. Hence perhaps something that could be bolted on in a utility library. Also the more help LTS provides out of the box the more people will use it...