brewie

Run mocha tests using Selenium.

npm install brewie
78 downloads in the last week
140 downloads in the last month

brewie

Description

brewie makes writing tests with wd.js and Selenium easy. We take care of all the setup that you need, using per environment configuration files, mixins, and easy multiple browser testing to make writing integration tests as effortless as possible.

Installation

To install brewie, we recommend using npm and installing it globally

npm install brewie -g

If you are going to use configuration constants in any of your tests you will also want to install config[1]

npm install config

Configuration

Structure

In a typical setup, you will want to create a folder to house your tests. The simplest way it to create a Tests folder at the root of your project. In that folder you will want a folder for config,mixins, and test.

Check the example project under /examples for a demonstration of how it should look.

Configuration Files

You will want to add a default configuration file, appropriately named default.js as well as a configuration file for each environment you plan to support. You might setup your development environment to run against a local instance of Selenium, while having the production instance target SauceLabs, for instance.

The default.js file should contain any configuration that you will need regardless of environment. This could be constants you want to access in your tests, or really anything you could need.

Browsers

As part of the evironment configuration, you can specify which browsers you want to test against.

browsers: [
  {
    browserName: 'chrome',
    tag: '1',
    name: 'modern.ie development test'
  },
  {
    browserName: 'firefox',
    tag: '2',
    name: 'modern.ie development test'
  }
]

This example illustrates running tests on a local Selenium environment. If you were running against SauceLabs, there are additional properties you can assign to specify browser version, platform, and any other SauceLabs supported data

{
  browserName: 'chrome',
  platform: 'Windows 8',
  version: '27',
  'selenium-version': '2.35.0',
  name: 'modern.ie production test'
}

Mixins

Any mixins you add will be added to the global browser object so you can easily access them when running your tests. Be mindful that brewie uses wd.js' promise implementation heavily and your mixins should support this if you want to chain them.

Usage

Installing Selenium and the web drivers

  1. Install any browser versions you'd like to test in locally.

  2. Install java if it is not already installed.

  3. Download the latest version of Selenium server - http://docs.seleniumhq.org/download/

  4. Download drivers for any browsers you'd like to support (Firefox is supported natively, without a driver).

Starting the Selenium server

Open a Terminal window or Command Prompt (Windows) and type in one of the examples below. Be sure to replace the path with the path to your Selenium server file and drivers in the examples below. If java is not available, you might need to install it or include it in your system path.

Example of starting a Selenium server instance. By default this only supports Firefox.

java -jar /path/to/your/selenium-server-standalone-2.3X.0.jar -p 4444

Example of starting a Selenium server instance that supports Firefox, IE and Chrome in Windows

java -jar /path/to/your/selenium-server-standalone-2.3X.0.jar -p 4444 -Dwebdriver.ie.driver=/path/to/IEDriverServer.exe -Dwebdriver.chrome.driver=/path/to/chromedriver.exe

Example of starting a Selenium server instance that supports Firefox and Chrome in OSX

java -jar /path/to/your/selenium-server-standalone-2.3X.0.jar -p 4444 -Dwebdriver.chrome.driver=/path/to/chromedriver

Running Brewie

The brewie commandline tool comes with several options that you can view by running

brewie -h

You can simply run brewie, using the defaults, and it will run your tests as long as your files are all in the correct place. Otherwise, you will need to specify where your tests are, where your mixins file is, and any other configuration you may need to change.

Example

brewie -R spec -T test/ -m mixins/mixins.js

Building

brewie uses TypeScript for much of its source, so if you are building brewie, there is a provided grunt task that will compile the TypeScript as well as run JSHint on all the files.

npm loves you