On the SitePoint PHP blog there's a tutorial posted that introduces you to Laravel Dusk, a browser-based testing tool, and how it can be used to test a Laravel-based application.

End to end testing for JavaScript applications, particularly single-page-apps, has always been a challenge. To that end, Laravel released its 5.4 version recently with a new testing library: Dusk.

With the release of Dusk, Laravel hopes to give its users a common API for browser testing. It ships with the default ChromeDriver, and if we need support for other browsers, we can use Selenium. It will still have this common testing API to cater to our needs.

The tutorial then walks you through the installation process and two approaches to getting it integrated into your application. They then create a first test, checking to see if a user can log in successfully. They also include how it looks when a test fails and the screenshot that's taken just before the failure. It also covers the testing of Ajax-related calls, inserting a delay when a button is clicked to wait for the response. Finally, the tutorial shows a more advanced example involving a popup modal, a form and multiple interactions.

Kicking off his series of posts looking at the new features that come along with the v5.4 release of the Laravel Framework Matt Stauffer has posted a look at Dusk, a tool that makes it simpler to test your Laravel based applications.

If you follow anyone in the Laravel world on Twitter, or if you listen to the Laravel Podcast, you know by now that Laravel Dusk is the new face of application testing in the Laravel world.

[...] With Dusk, Taylor has completely re-written how application testing works in Laravel. Everything is now based on a tool called ChromeDriver, which is a standalone server that actually controls Chrome/Chromium. When you write application tests, Dusk sends your commands to ChromeDriver, which then spins up Chrome to run your tests in the browser and then reports back the results.

He starts with a brief look at how testing was being performed in most cases on Laravel applications (using the "Integrated" package) but pointed out that that only really worked for non-Javascript driven sites. With the introduction of Dusk and it's use of the ChromeDriver to make "browsing" in the test simpler. He includes the installation process of the latest version of Dusk and an example test checking to be sure the string "Laravel" is in a page. He includes a gif of the test in action and talks about some of the new interactions and assertions included in the tool. He wraps up the post looking at the use of Pages and a few other miscellaneous tips to help you get your testing up and working productively.

On the Laravel News site there's an announcement posted about a new tool coming to the Laravel ecosystem - Laravel Dusk. Dusk is a browser testing tool that makes it easier to test Laravel-based Javascript-heavy applications.

When you write end-to-end tests, Laravel provides a set of useful helper methods which make it easy to click a link, fill an input field, or submit a form. Under the hood, Laravel uses the Symfony BrowserKit component to simulate the behavior of the web browser. However, if your app uses JavaScript and AJAX to load the page, BrowserKit will not work for you.

Laravel Dusk is a new tool that will be introduced in Laravel 5.4 to solve this problem.

The post goes on to talk about the tool and what kind of functionality powers it - a combination of ChromeDriver and the Facebook PHP-Webdriver packages. The testing process is claimed to be faster than normal Selenium tests and feels more "natural" than BrowserKit testing. Dusk will save screenshots of failures automatically and comes with helper methods, multiple window support and a Dusk-specific environment file.