node package manager!

API Reference | CLI | CSS Selectors | Features and Definitions | Config | Modules

Garden is a BDD testing framework for browser based apps and websites.

It's built on Node.js, cucumber.js, Selenium WebDriver API.

Main Features

  • Simple API to manage browser (WebDriver)
  • Using CSS3 selectors to interact with DOM
  • All network interactions data are accessible within the tests (headers, body, size etc)
  • Built-in command-line test runner
  • Head and headless browser testing (phantom.js, chrome, firefox)


  • node.js, java
  • phantomjs optional, but uses by default

Getting started

  • sudo npm install --global # install plus garden
  • init xxx-project # init garden structure
  • cd xxx-project # go inside
  • test # run smoke/healthy tests, it executes next scenario:
  Scenario: I want to see good health
    Given  I am on external host ""
    Then   status code should be 200
    Then   take screenshot

Local dependency way

Make a new directory, and cd into it:

mkdir my-new-project && cd $_

Run npm init and go through hints

npm init

Install garden as a dependency

npm install --save

Init directory structure

node node_modules/ init

run first test

node garden.js test


Garden generates the simplest scenario by default:

[your folder]/features/Health.feature

 Scenario: I want to see good health
   Given  I am on external host ""
   Then   status code should be 200
   Then   take screenshot

with step defenitions that cover this, it looks like:

[your folder]/features/step_definitions/common.js

    this.Given(/^I am on "(.+)"/, function (url, callback) {
    this.Given(/^I am on external host "(.+)"/, function (url, callback) {
    this.Given(/^I am on homepage$/, function (callback) {
    this.Given(/^I should be on "([^"]*)" page$/, function(expectedTitle, callback) {
    this.Then(/^status code should be (\d+)$/, function(statuscode, callback) {
    this.Then(/^take screenshot$/, function (callback) {

Full example of this you can find in features folder:

  • features/Health.feature # feature file
  • features/step_definitions/common.js # javascrip support

More details about features and definitions and API Reference you can find here


Usually we need fixtures in our applications to have some sandbox. This functionality available via modules. For example mongodb fixtures looks like this:

    exports.users = [
        { name: 'Gob' },
        { name: 'Buster' },
        { name: 'Steve Holt' }

and garden loads this in tests and in CLI.

./garden.js fixtures.load
./garden.js fixtures.drop

For now garden supports mongodb and mysql fixtures via modules. Feel free to develop new ones.

For more examples please take a look:

RESTFul API testing

When we develop web-service/micro-services we need to test RESTFul API. That is great ability to test api and have some user friendly specification for this. It looks like this one:

    # demo/get.feature
    Feature: Make a GET request
        In order to programmatically access
        As a Web Service User
        I need to have an ability to make a GET request and check response
        Scenario: Make a GET request to Fake Online REST API
          When I make GET request to ""
          Then the status code should be 200
           And content type should be "application/json; charset=utf-8"
           And the JSON response should be:
             "userId": 1,
             "id": 1,
             "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
             "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"


Full list of modules we will publish here (Modules)

Be Happy!

And cover you stuff with tests!