Laravel Dusk an excellent tool for browser automation testing, provided as a official package by Laravel. Laravel Dusk was introduced with Laravel version 5.4

Dusk is built upon open source tools like Php-WebDriver and ChromeDriver , and it does not require setting up JDK or Selenium for it to work. Dusk provides a nice abstraction layer on the top of php-webdriver, which makes it a very easy tool to work with. And since php-webdriver is backed by Facebook, dusk guarantees a robust API.

Why Dusk ?

Prior to dusk, Laravel used symphony browserkit for browser simulation testing but it's not close to a real browser. Dusk uses chromedriver which is an actual browser. Thus if you are testing a javascript heavy application dusk comes out very handy.

Dusk can be used for end-to-end testing for your application which is important if your application goes through a refactor in later stages and to test if new components / features does not break the functionality that already exists.

Since dusk can be used to visit any website automatically, it can also be used for web scraping and crawling.

How is it different from phpUnit ?

Although with phpUnit you can test your features via API endpoints testing and page response. But phpUnit does not provide an end-to-end browser simulation for your tests. Dusk uses chromedriver to execute the tests, and thus the testing will be very close to an actual user using the application.

Laravel Dusk Tutorial

Although Dusk has a solid documentation, I found few bit's and pieces of missing information over the web when I started working with Laravel Dusk. I have created a list of tutorials on how to work with Dusk. Tutorial include how you install and get going with dusk, working with database in dusk, interacting with elements, working with Forms, understanding the concept of pages and components, how and why to wait for an element, and other's.

You can go over the dusk articles as given in the left navigation.

As I work with dusk I will keep adding more articles based on what new thing I encounter.

Comment below if you want me to cover any dusk related topic which is not covered yet.

 

Comments