Debug extension for Behat
MinkDebugExtension is a Behat extension made for debugging and logging Mink related data after every failed step. It is especially useful while running tests on continuous integration server like Travis. While using Selenium2 driver, you can also save screenshots just after the failure.
Moreover, it comes bundled with some useful scripts, that will make uploading logs and screenshots extremely easy.
Assuming you already have Composer:
composer require lakion/mink-debug-extension
Then you only need to configure your Behat profile:
default: extensions: Lakion\Behat\MinkDebugExtension: directory: directory-where-to-save-logs
Lakion\Behat\MinkDebugExtension there are three options to be configured:
directory(required to enable extension) - contains path to directory that will contain generated logs. Use the variable
%paths.base%to refer to the directory where your
false) - whether to save screenshots if using
true) - whether to clean your existing logs on each Behat execution
MinkDebugExtension comes with three tiny, but powerful scripts. They will be installed to your
vendor/bin by default.
vendor/bin/upload-textfiles "<glob_path>" - uploades file contents to termbin.com and returns a list of file names and urls to uploaded content.
Glob paths must be quoted to work correctly. Usage:
$ vendor/bin/upload-textfiles "logs/*.log" $ vendor/bin/upload-textfiles README.md
vendor/bin/upload-screenshots "<glob_path>" - uploades images to imgur.com and returns a list of file names and theirs urls.
Glob paths must be quoted to work correctly. Requires Imgur API key to be set as environmental variable
$ export IMGUR_API_KEY="imgur api key" $ vendor/bin/upload-screenshots "logs/*.png" $ vendor/bin/upload-screenshots favicon.ico
vendor/bin/wait-for-port <port> [limit = 15] [interval = 1] - waits for service to appear at localhost at a given port, useful while waiting for Selenium or webserver to warm up.
Limit is the number of tries, interval is the delay in seconds between another tries. Usage:
$ java -jar selenium.jar & $ vendor/bin/wait-for-port 4444
In order to test the extensions run:
composer install bin/phpspec run bin/behat --strict