Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

squibby's avatar

Is there any way to show browser window when running dusk tests from within homestead?

I have multiple Dusk tests which I run inside homestead. I need to run inside homestead because I tear down and reseed the DB after for each test. My current tests work fine, but I would like to see the browser play out the tests. This would be useful for me when I am creating long dusk tests and can visually see whats going on.

I know If I run tests outside of homestead the browser window pops up and steps through each task.

How can I display whats going on but still run from homestead? Has anyone does this before?

Thanks.

0 likes
7 replies
bashy's avatar

Doubt you can really do that since you'd need a desktop environment for Homestead (Ubuntu).

I'd just run them locally. I seed the whole database each Dusk test for mine. It's not that slow.

squibby's avatar

I migrate and seed for each test also. If I try to run outside of homestead this wont work as I have no connection to DB.

I am using Mysql for DB. If I switch to sqlite for testing database will I be able to connect outside of homestead? Is that how you are able to run tests like this locally..?

I am going to look at using sqlite connection and give that a try. That should also should speed up the tests i hope. Currently each test can take a few minutes to run.

Thanks.

bashy's avatar

You can connect to Homestead database remotely if it's setup to do so. You can read about that on Laracasts' forums - probably find an answer I've entered :P

1 like
squibby's avatar

ok thanks, I will take a deeper look. :-)

squibby's avatar
squibby
OP
Best Answer
Level 8

I sorted this with thanks to @bashy

I just changed port from 3306 to 33060 in my .env.dusk.local file. Everything now works as I wanted it to. Not sure why I didn't realise this as I already connect sequel pro like this.

Edit: Also worth mentioning is that changing to 33060 allows the migrations and seeds to run but does not connect and retrieve data when the browser is used in the Dusk tests. 33060 / 3306 need to be toggled depending on what is happening. This can be solved by following this:

https://www.thomasedwards.co.uk/tutorials/installing-chromedriver-on-macos

martijnimhoff's avatar

Thanks for this topic, changing the port worked for me.

However I still had issues with the database, even after following the tutorial of Thomas. I managed to fix it. Instead of checking if Laravel is running from the console, I check the hostname. It looks like this:

I added these lines of code to my AppServiceProvider:

if($this->app->environment() === 'local' && gethostname() !== 'homestead') {
    config()->set('database.connections.mysql.port', 33060);
}

And perhaps it is best to set the hostname and port through your .env.dusk.

arcode's avatar

Having the same problem, although the solution in the link from 'best answer' didn't work for me yet. Neither changing it a bit with what Martijnimhoff is suggesting. Anything related to the DB needs to go through port 33060 however then when doing just a standard application test like checking if the homepage loads it crashes because that just needs port 3306. So far switching them has not been succesful for me.

Please or to participate in this conversation.