1
votes

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!

1
Dusk runs under PHPUnit so.... PHPUnit kind of supports crawling the browser, but not out of the box, and needs libraries like... Dusk. Seriously though, unit tests like the traditional tests you'd find in your PHPUnit suite and end-to-end tests like Laravel's HTTP tests and Dusk tests serve a completely different purpose and you need to have both in most casesapokryfos

1 Answers

3
votes

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.