Using Laravel Dusk for other web applications
There comes a time when something pretty wicked is released, but in your development cycle you are too far into an older version, or different framework to use that pretty new thing.
Currently we work with a bunch of different frameworks, and within those frameworks they can all have their own versions. This can create a pretty big hassle when dealing with testing. Let’s be honest and usually nobody has “time” to write these tests but when you do, you want to use what is the best thing available to you.
We wanted to use Laravel Dusk for our Laravel 5.2 application as upgrading was just no feasible in the amount of time we had. Sadly, Laravel Dusk was released for Laravel 5.4 so it seemed like we could not use it.
And this is the main reason for this blog post. This post is a little reminder that your tests and application do not always have to be in the same repository. We decided to install a default Laravel 5.5 with Dusk and use that for our testing. There is nothing else installed on that project except for Dusk.
So we have two repositories for one of our projects. Our first repository is our main code that always gets updated, and the second repository is the Laravel Dusk instance that only contains tests for that application.
When we setup our testing repository after writing a few tests the only changes that our developers need to make is within the
.env file of their application, specifically the
app_url. They can decide the point the testing at their local machine, or we can point the entire test at our staging environment. This makes things so much nicer, and when a big change comes in we can easily test the local environment before pushing any changes up the main branch even though Dusk is for Laravel 5.4 and up.
It is that simple and some times we like to over think things and make them super complicated. Not always do we have time to update our projects, or switch frameworks.