Search code examples
laravelphpunitcrudlaravel-dusk

Laravel CRUD Application Dusk vs PHPUnit


I am currently working on a Laravel CRUD application and I was wondering why PHPUnit does not support crawling the browser (anymore, as I read). I already covered the basement of my project via PHPUnit, but I do also want to test links, a tags, button clicks etc. So I do already have a strong basement of unit tests.

Now I read about Dusk providing a crawler for DOM tests. Shall I use both together (is it even possible?) or should I migrate to Dusk? I'm not sure whether Dusk provides the same functionality as PHPUnit does and as stated, I do already have a strong phpunit testing base.

From now on I'm kinda stuck, because of 50:50 testcases, as I do also need to test whether the DOM does provide the correct information.

Appreciate any help or expert advice.

Thank you in advance!


Solution

  • Dusk is not a crawler but a browser driver, it can control a (headless) browser.

    Specifically designed on top of PHPunit to do E2E (end to end) testing.

    So convert to Dusk what is browser tests (html/javascript), but everything else keep as unit tests.

    API tests for example you don't need dusk at all.