Simple debugging for Mink errors locally and on your CI server.
PHP Shell Gherkin
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
features
src
test-application
travis
.gitignore
.travis.yml
CHANGELOG.md
README.md
composer.json
phpspec.yml.dist

README.md

MinkDebugExtension

License Version Total Downloads Build status... Scrutinizer Quality Score

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.

Installation

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

Configuration reference

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 your behat.yml is
  • screenshot (default false) - whether to save screenshots if using Selenium2Driver
  • clean_start (default true) - whether to clean your existing logs on each Behat execution

Scripts

MinkDebugExtension comes with three tiny, but powerful scripts. They will be installed to your config.bin-dir directory, which is vendor/bin by default.

Uploading textfiles

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

Uploading screenshots

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 $IMGUR_API_KEY. Usage:

$ export IMGUR_API_KEY="imgur api key"

$ vendor/bin/upload-screenshots "logs/*.png"
$ vendor/bin/upload-screenshots favicon.ico

Waiting for port to be taken

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

Testing

In order to test the extensions run:

composer install
bin/phpspec run
bin/behat --strict

Authors

MinkDebugExtension was originally created by Kamil Kokot. See the list of contributors.