openeuropa/behat-transformation-context

Behat package to transform human readable labels into selectors or page paths.

0.2.0 2023-01-03 14:38 UTC

This package is auto-updated.

Last update: 2024-09-30 01:24:37 UTC


README

Build Status Packagist

This package provides a Behat context allowing to transform human readable labels to selectors or page paths. Such functionality improves the readability of the Behat tests.

Installation

$ composer require openeuropa/behat-transformation-context

Configuration

Add the extension and context to your test suite in behat.yml:

default:
  suites:
    default:
      contexts:
        - OpenEuropa\Behat\TransformationContext:
            elements:
              header: 'div#header'
            pages:
              home: 'index.php'

Usage

We can use steps such as these:

    Given I point to *the home page*
    Then previous step targets "*index.php*"
    When I point to the "*header*" element
    Then previous step targets "*div#header*"

Development

Running tests locally:

$ git clone git@github.com:openeuropa/behat-transformation-context.git
$ cd behat-transformation-context
$ composer install
$ ./vendor/bin/behat

Using Docker Compose

The setup procedure described above can be sensitively simplified by using Docker Compose.

Requirements:

Run:

$ docker-compose up -d

Then:

$ docker-compose exec web composer install

GrumPHP tasks will be ran at every commit, if you with to run them without performing a commit use the following command:

$ ./vendor/bin/grumphp run

If you want to simulate a commit message use:

$ ./vendor/bin/grumphp git:pre-commit

Step debugging

To enable step debugging from the command line, pass the XDEBUG_SESSION environment variable with any value to the container:

docker-compose exec -e XDEBUG_SESSION=1 web <your command>

Please note that, starting from XDebug 3, a connection error message will be outputted in the console if the variable is set but your client is not listening for debugging connections. The error message will cause false negatives for PHPUnit tests.

To initiate step debugging from the browser, set the correct cookie using a browser extension or a bookmarklet like the ones generated at https://www.jetbrains.com/phpstorm/marklets/.