Using Zombie.js Driver with Behat’s MinkExtension[Updated]


Zombie.js is a headless browser which uses Node.js, NPM, a C++ compiler and Python. We can use Zombie.js with Behat’s MinkExtesion to make your BDD scenarios much faster. We have seen that we can also use Selenium, WebDriver, Sahi etc etc with MinkExtension.

Here are few Benefits you can achieve using Zombie.js

  • You don’t need browser so your tests become so fast.
  • You don’t need to launch Server before running tests, Zombie will automatically do it for you, saving your time and efforts.
  • Robust automated tests.
  • Easy to setup on Linux and Mac OSX servers.

Being honest, it was pain in everywhere until I got Zombie working in my local machine. I managed to get it working on Linux (Ubuntu) by taking help from Behat community, but faced many issues while getting it work on my Mac OSX. Finally, I have everything setup!!


On Ubuntu

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs nodejs-dev npm
$ node --version
$ npm
$ npm install -g zombie

On Mac OSX

You need to have Xcode and HomeBrew installed.

$ brew install node
$ node --version
$curl | sudo sh
$npm --version
$ sudo npm install -g zombie

 My terminal window looks like this after installation:

Node NPM

Node NPM



 Next, you need to add NODE_PATH envirnomental variable to your .bashrc Or .bash_profile. It’s time consuming to find out right ‘node_module’ where ‘zombie’ is installed. You have to do it in a right way other wise you will end up with error 

 Server process has been terminated: (1) [

          throw err;
      Error: Cannot find module 'zombie'
          atFunction Module.resolveFilename (module<js:338:15)
          at Function.Module._load (module.js:280:25)
          at Module.require (module.js:362:17)
          at require (module.js:378:17)
          at Object.&amp;lt;anonymous&amp;gt; (/tmp/mink_nodejs_serveruehqa6:2:16)
          at Module._compile (module.js:449:26)
          at Object.Module._extensions..js (module.js:467:10)
          at Module.load (module.js:356:32)
          at Function.Module._load (module.js:312:12)
          at Module.runMain (module.js:492:10)

It’s so annoying error so it’s fucking important to add right NODE_PATH to your .bashrc / .bash_profile

On Mac OSX

$ sudo vim .bashrc

Now insert following code, We are going to add ‘npm’ in the PATH and NODE_PATH

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/bin/npm:$PATH"
export NODE_PATH="/usr/local/share/npm/lib/node_modules"

 On Ubuntu

export NODE_PATH="/usr/lib/node_modules"


Create Behat-Mink-Zombie Project

Now, Let’s create sample project which uses Mink-Extension with Zombie driver. Let’s call this Project as ‘Behat-Mink-Zombie’

mkdir Behat-Mink-Zombie
cd Behat-Mink-Zombie
  • Create composer.json
    "require": {
        "behat/behat": "2.5.*@stable",
        "behat/mink": "1.5@stable",
        "behat/mink-extension": "*",
        "behat/mink-zombie-driver": "*"

    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"


  • Create a simple ‘behat.yml’ config file
            default_session: zombie
            javascript_session: zombie
              node_modules_path: '/usr/local/share/npm/lib/node_modules/'
  • Install Behat and other dependencies using composer.
$ curl | php
$ php composer.phar install
  • Initialize Behat
$ ./bin/behat --init
+d features - place your *.feature files here
+d features/bootstrap - place bootstrap scripts and static files here
+f features/bootstrap/FeatureContext.php - place your feature related code here
  • Create a Simple Feature File in ‘features’ directory
$ sudo vim BlogSearch.feature

Now write a features with some user actions.

Feature: Blog Search
	In order to search blogs
	As a sauce user
	I need see blogs

Scenario: Search Behat Blogs
Given I am on "/blog"
When I fill in "s" with "behat"
And I press "Search"
Then I should see "Adding Sauce To Behat"
  • Extend Auto-Generated ‘FeatureContext.php’ to Mink Extension.

Delete all the unwanted code, It should look like this:


class FeatureContext extends Behat\MinkExtension\Context\MinkContext

  • Run ‘behat’ and watch your tests passing by using headless Zombie Driver.



Great! You should be laughing at this point.


Source Code is also available on GitHub on “Behat-Zombie” repository. You can clone the repository and try it yourself by executing following commands in sequence. [I assume, you have Node, npm and Zombie installed ]

$git clone
$cd Behat-Zombie
$curl | php
$php composer.phar install


You can make your BDD scenarios more robust, faster and maintainable by using headless browsers like Zombies with BDD tools like Behat. Zombie.js is easy to setup on Linux and Mac OSX as part of Continuous Integration. Enjoy Mink-Extension with Zombie driver.