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
Under 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 yourbehat.yml
isscreenshot
(defaultfalse
) - whether to save screenshots if usingSelenium2Driver
clean_start
(defaulttrue
) - whether to clean your existing logs on each Behat execution
MinkDebugExtension comes with three tiny, but powerful scripts:
vendor/lakion/mink-debug-extension/travis/tools/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/lakion/mink-debug-extension/travis/tools/upload-textfiles "logs/*.log"
$ vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles README.md
vendor/lakion/mink-debug-extension/travis/tools/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 varialbe $IMGUR_API_KEY
. Usage:
$ export IMGUR_API_KEY="imgur api key"
$ vendor/lakion/mink-debug-extension/travis/tools/upload-screenshots "logs/*.png"
$ vendor/lakion/mink-debug-extension/travis/tools/upload-screenshots favicon.ico
vendor/lakion/mink-debug-extension/travis/tools/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/lakion/mink-debug-extension/travis/tools/wait-for-port 4444
In order to test the extensions run:
composer install
bin/phpspec run
bin/behat --strict
MinkDebugExtension was originally created by Kamil Kokot. See the list of contributors.