PHPackages                             node/behat-html-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. node/behat-html-formatter

ActiveLibrary[Testing &amp; Quality](/categories/testing)

node/behat-html-formatter
=========================

This will create a html formatter for Behat.

027PHPCI failing

Since Oct 24Pushed 6y agoCompare

[ Source](https://github.com/nodeJerry/behat-html-formatter)[ Packagist](https://packagist.org/packages/node/behat-html-formatter)[ RSS](/packages/node-behat-html-formatter/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

BehatHtmlFormatterPlugin
------------------------

[](#behathtmlformatterplugin)

Behat 3 extension for generating HTML reports from your test results.

[![Latest Stable Version](https://camo.githubusercontent.com/b624f3d8b65df721b33d2d608107ea9d0d0dffd9c294d70e75148f2d2b8e053a/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f762f737461626c65)](https://packagist.org/packages/emuse/behat-html-formatter) [![Total Downloads](https://camo.githubusercontent.com/a2c14bf21b8ff4e9883967299db67599ae2134ae633ff1303a875c6bbea51d30/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/emuse/behat-html-formatter) [![Latest Unstable Version](https://camo.githubusercontent.com/d60b72aa191247119e269033f6dffb1aac4e390da0dad8f8c40b6fb2eaaa600a/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f762f756e737461626c65)](https://packagist.org/packages/emuse/behat-html-formatter) [![License](https://camo.githubusercontent.com/4ccafe8fb0975cfdbda3d09c9596da813ad459067a4aa7cbbcbd0e8612675f49/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/emuse/behat-html-formatter)

### Twig report

[](#twig-report)

[![Twig Screenshot](https://camo.githubusercontent.com/0ef008d88774d969ed2f514f75e7879ee9e402699b7f4f81a741e0fe8cbe4ed3/687474703a2f2f692e696d6775722e636f6d2f6f307a437169422e706e67)](https://camo.githubusercontent.com/0ef008d88774d969ed2f514f75e7879ee9e402699b7f4f81a741e0fe8cbe4ed3/687474703a2f2f692e696d6775722e636f6d2f6f307a437169422e706e67)

### Behat 2 report

[](#behat-2-report)

[![Behat2 Screenshot](https://camo.githubusercontent.com/c5cc587370c2d3ecab4d808ab2d5e8a5e5c041db86ae48468d658088c94eb6fe/687474703a2f2f6935372e74696e797069632e636f6d2f323837673934322e6a7067)](https://camo.githubusercontent.com/c5cc587370c2d3ecab4d808ab2d5e8a5e5c041db86ae48468d658088c94eb6fe/687474703a2f2f6935372e74696e797069632e636f6d2f323837673934322e6a7067)

How?
----

[](#how)

- The tool can be installed easily with composer.
- Defining the formatter in the `behat.yml` file
- Modifying the settings in the `behat.yml`file

Installation
------------

[](#installation)

### Prerequisites

[](#prerequisites)

This extension requires:

- PHP 5.3.x or higher
- Behat 3.x or higher

### Through composer

[](#through-composer)

The easiest way to keep your suite updated is to use [Composer](http://getcomposer.org%3E):

#### Install with composer:

[](#install-with-composer)

```
$ composer require --dev emuse/behat-html-formatter
```

#### Install using `composer.json`

[](#install-using-composerjson)

Add BehatHtmlFormatterPlugin to the list of dependencies inside your `composer.json`.

```
{
    "require": {
        "behat/behat": "3.*@stable",
        "emuse/behat-html-formatter": "0.1.*",
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}
```

Then simply install it with composer:

```
$ composer install --dev --prefer-dist
```

You can read more about Composer on its [official webpage](http://getcomposer.org).

Basic usage
-----------

[](#basic-usage)

Activate the extension by specifying its class in your `behat.yml`:

```
# behat.yml
default:
  suites:
    ... # All your awesome suites come here

  formatters:
    html:
      output_path: %paths.base%/build/html/behat

  extensions:
    emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
      name: html
      renderer: Twig,Behat2
      file_name: index
      print_args: true
      print_outp: true
      loop_break: true
```

Configuration
-------------

[](#configuration)

- `output_path` - The location where Behat will save the HTML reports. The path defined here is relative to `%paths.base%` and, when omitted, will be default set to the same path.
- `renderer` - The engine that Behat will use for rendering, thus the types of report format Behat should output (multiple report formats are allowed, separate them by commas). Allowed values are:
- *Behat2* for generating HTML reports like they were generated in Behat 2.
- *Twig* A new and more modern format based on Twig.
- *Minimal* An ultra minimal HTML output.
- `file_name` - (Optional) Behat will use a fixed filename and overwrite the same file after each build. By default, Behat will create a new HTML file using a random name (*"renderer name"*\_*"date hour"*).
- `print_args` - (Optional) If set to `true`, Behat will add all arguments for each step to the report. (E.g. Tables).
- `print_outp` - (Optional) If set to `true`, Behat will add the output of each step to the report. (E.g. Exceptions).
- `loop_break` - (Optional) If set to `true`, Behat will add a separating break line after each execution when printing Scenario Outlines.

Screenshot
----------

[](#screenshot)

The facility exists to embed a screenshot into test failures.

Currently png is the only supported image format.

In order to embed a screenshot, you will need to take a screenshot using your favourite webdriver and store it in the following filepath format:

results/html/assets/screenshots/{{feature\_name}}/{{scenario\_name}}.png

The feature\_name and scenario\_name variables will need to be the relevant item names without spaces.

Below is an example of FeatureContext methods which will produce an image file in the above format:

```
        /**
         * @BeforeScenario
         *
         * @param BeforeScenarioScope $scope
         *
         */
        public function setUpTestEnvironment($scope)
        {
            $this->currentScenario = $scope->getScenario();
        }

        /**
         * @AfterStep
         *
         * @param AfterStepScope $scope
         */
        public function afterStep($scope)
        {
            //if test has failed, and is not an api test, get screenshot
            if(!$scope->getTestResult()->isPassed())
            {
                //create filename string
                $featureFolder = str_replace(' ', '', $scope->getFeature()->getTitle());

                $scenarioName = $this->currentScenario->getTitle();
                $fileName = str_replace(' ', '', $scenarioName) . '.png';

                //create screenshots directory if it doesn't exist
                if (!file_exists('results/html/assets/screenshots/' . $featureFolder)) {
                    mkdir('results/html/assets/screenshots/' . $featureFolder);
                }

                //take screenshot and save as the previously defined filename
                $this->driver->takeScreenshot('results/html/assets/screenshots/' . $featureFolder . '/' . $fileName);
            }
        }

```

Note that the currentScenario variable will need to be at class level and generated in the @BeforeScenario method as Behat does not currently support obtaining the current Scenario in the @AfterStep method, where the screenshot is generated

Issue Submission
----------------

[](#issue-submission)

When you need additional support or you discover something *strange*, feel free to [Create a new issue](https://github.com/dutchiexl/BehatHtmlFormatterPlugin/issues/new).

License and Authors
-------------------

[](#license-and-authors)

Authors:

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a86594157f7c04cfc2268b6bbeeb160be2638231ba06d6323b7a354196e22305?d=identicon)[timFort](/maintainers/timFort)

---

Top Contributors

[![nodeJerry](https://avatars.githubusercontent.com/u/33423683?v=4)](https://github.com/nodeJerry "nodeJerry (1 commits)")

### Embed Badge

![Health badge](/badges/node-behat-html-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/node-behat-html-formatter/health.svg)](https://phpackages.com/packages/node-behat-html-formatter)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
