My project is in Laravel 5.4 framework and I use Dusk for browser tests. I have a page with several sections that I would like to check on my own, however, I encountered a problem when I need to launch a new browser instance, log in and go to this page for each individual test.
public function testExample() { $this->browse(function (Browser $browser) { $browser->loginAs(1) ->visit('/admin/dashboard') ->assertABC() ->assertXYZ(); }); }
So, when I have 4-5 of them in the class allTheThingsTest extends DuskTestCase , I create 4-5 browser instances for each test class. Obviously, this quickly gets out of hand, especially when I run all of my pre-deployments.
One browser instance per test class is acceptable as far as I know, but I cannot figure out how to do this. So here is what I ask:
- Is it possible to remember / reuse a browser instance between test functions within the same test class?
- If so, how?
php laravel laravel-dusk
amflare
source share