kanav_kapoor liked a comment+100 XP
5mos ago
I'm writing tests for an Inertia app in Dusk and using waitUntilMissing('#nprogress') calls to delay the assertions until the new content loads. This solution works fine-ish, but I noticed that when I start up my computer, come back to it after a while away, or make certain kinds of changes to my front-end code, random Dusk assertions will fail at run-time. The failing assertions change each time I run Dusk until I've run it 3-6 times, at which point, it will return consistent results again. After some reading, it looks like the cause of the issue is:
By default, this will pause the test for a maximum of five seconds before throwing an exception. If necessary, you may pass a custom timeout threshold as the second argument to the method.
(https://laravel.com/docs/8.x/dusk#waiting-for-elements)
The delay seems to go past 5 seconds while Homestead caches the app (? - I assume so, because it is also slow to load in browser after first booting up), so it's not stemming from a real performance issue. My current solutions to the issue are:
a. Re-run Dusk 3-6 times every time I get a failure that looks like it might be because of this issue.
b. Add much longer custom thresholds to waitFor/waitUntilMissing calls in tests.
My issues with a. are that it makes it harder to use Dusk reliably for testing and it makes the process of checking the app with Dusk very, very slow. b. is not so bad, but it does make testing slower and make Dusk much less likely to tell me if there is a real issue with performance.
My questions are:
- Is there a way to fix the apparent caching issue (or whatever the cause is) in Homestead that I'm missing? (Running php artisan cache:clear seems to have no effect, so I think it is specifically Homestead and not the Laravel app causing this.)
- Is there a way of changing the default 5 second setting globally for all waitFor/waitUntilMissing calls?