Laravel 5: Testing – Laravel Dusk – browser testing – general info

Testing – Laravel Dusk – browser testing – general info

Laravel Dusk is enriched replacement for ‘Integrated Package’.

Laravel Dusk requires extra setup. More: read here.
Cheatsheets
Most used Testing assertions are described here:
  1. PHPunit testing
  2. Dusk browser testing (selenium-like)

Rest of them can be found in this directory: vendor\laravel\dusk\src\Concerns\

General
Generating Dusk test files

Running Dusk tests

You can run @group PHPUnit annotation:

… but you cannot run –testsuite:

Fortunately, you do not have to use php artisan dusk at all.
Just use standard phpunit commands for dusk using testsuites and groups and other annotations, e.g.:

or

For testsuite, you have to add to phpunit.xml:

 

Now you have access to all commands standard PHPUnit runs, like:

  • –filter <pattern> : Filter which tests to run.
  • –testsuite <pattern> : Filter which testsuite to run.
  • –group … : Only runs tests from the specified group(s).
  • –exclude-group … : Exclude tests from the specified group(s).
  • –list-groups : List available test groups.
  • –list-suites : List available test suites.
  • –test-suffix … : Only search for test in files with specified suffix(es)

 

More PHPUnit CLI commands – here.

Some samples
Creating Browsers

Browser is a set of instructions testing some functionality as user would by opening browser and interacting with it.

Lets take this ‘browser’ for example:

So, as you see in comments above, you just construct – step by step scenario, exactly resembling actions a normal user would do.
If this is not intuitive … I do not know what is.

Lets see another example, where actions had to be split among multiple ‘browsers’.

Great stuff.


Next page: detailed info about all available tools.