Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing Laravel Dusk

Introducing Laravel Dusk

Laravel Dusk provides an expressive, easy-to-use browser automation and testing API. Dusk makes it possible to run your Browser tests without any installation of drivers on your machine since it uses the standalone ChromeDriver. This talk will learn you the ins and outs of browser testing. We will use Laravel Dusk too test an application that is build with a VueJS frontend and Laravel backend.

Bobby Bouwmann

May 10, 2019
Tweet

More Decks by Bobby Bouwmann

Other Decks in Programming

Transcript

  1. Introducing
    Laravel Dusk

    View Slide

  2. About me
    » Bobby Bouwmann
    » @bobbybouwmann
    » Developer @ Enrise - Code Cuisine
    » Top contributor Laracasts
    » Creator of https://markdownmail.com

    View Slide

  3. View Slide

  4. Agenda
    » What is Laravel Dusk?
    » What is Browser testing?
    » When to apply Browser testing?
    » Why use Laravel Dusk?
    » Laravel Dusk - the code
    » Demo Time
    » Caveats

    View Slide

  5. Let's talk
    Laravel Dusk

    View Slide

  6. What is Laravel Dusk?
    “Laravel Dusk provides an expressive, easy-to-use
    browser automation and testing API. By default, Dusk
    uses a standalone ChromeDriver installation.”

    View Slide

  7. What is Browser testing?
    » Testing to enruse application works as expected in
    a given browser
    » Test JavaScript based application functionality
    » Checking links, popups, menus

    View Slide

  8. Manual vs Automated
    » Developer, product owner, user/customer clicking
    around
    » Automated using some tool

    View Slide

  9. Manual Browser testing
    » Clicking through application
    » Testing different devices, versions and browsers
    » Takes a lot of time
    » Repeating work
    » Multiple browser versions
    » Focus on responsive
    » Error prone

    View Slide

  10. Automated Browser testing
    » Continious Integration (CI)
    » Testing multiple browsers, versions at the same
    time
    » Complex setup (we'll see about that!)
    » Has to be maintained

    View Slide

  11. Automated Browser testing tools
    » Laravel Dusk 4.x (since 2017, Laravel 5.4)
    » Selenium 3.x (since 2004)
    » Cypress.io 3.x (since 2017)
    » PhantomJS 2.x (since 2011)
    » Paid services (Selenium as a Service)

    View Slide

  12. When to apply it
    » Our responsibility as developers to make sure the
    project works for all users, not matter what
    browser or device

    View Slide

  13. View Slide

  14. View Slide

  15. When to apply it
    » Order or payment flows
    » Oauth flows with other parties
    » Making screenshots/videos
    » Automating processes on websites

    View Slide

  16. View Slide

  17. Introducing
    Laravel Dusk

    View Slide

  18. Introducing Laravel Dusk
    » Browser testing for web applications
    » Browser abstraction on top of PHP-Webdriver
    » Doesn't require any JDK or other tool like
    Selenium
    » Comes with standalone ChromeDriver executable

    View Slide

  19. History of Laravel Dusk
    » Laravel 5.2: Symfony BrowserKit
    » Laravel 5.4: Laravel Dusk

    View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. View Slide

  35. View Slide

  36. View Slide

  37. View Slide

  38. Benefits of Dusk
    » Integrated with Laravel (auth, sessions, cookies)
    » Running seeds per test
    » Laravel syntax for writing tests
    » No extra installation of JDK's or Selenium
    » Can be used with Selenium or other tools as well

    View Slide

  39. Disadvantages of Dusk
    » Coupled to Laravel, harder to setup outside of the
    ecosystem
    » Missing a dashboard/tool to see a step-by-step
    overview of the tests

    View Slide

  40. CI integration
    » php artisan serve
    » chromedriver

    View Slide

  41. View Slide

  42. Demo time

    View Slide

  43. How to get started
    » There are tools or ready to go containers for you
    available!
    » You can use my setup
    » Start digging into this yourself!
    » Laravel TestTools

    View Slide

  44. A good use case
    » Monthly payments
    » Screenshots
    » Sending emails

    View Slide

  45. Laravel Dusk caveats

    View Slide

  46. Thank you!
    https://gitlab.com/bobbybouwmann/vault

    View Slide