Skip to content

Using Bender with Travis

Grzegorz Pabian edited this page Aug 13, 2014 · 2 revisions

You can run your tests in Bender using Travis CI!

Configure Bender

First of all you need to decide in which environment you want to test your code.

By default bender run command (used while integrating with CI tools) is executed headlessly in PhantomJS. However it is possible to change it to a real browser using bender.js configuration file or a command line option.

bender.js

var config = {
	applications: {...},

	framework: 'jasmine',

	plugins: [...],

    // override the default browser with Firefox
	startBrowser: 'firefox',

	tests: {...}
};

module.exports = config;

Here we configure Firefox to be our default browser for bender run command:

$ bender run -b firefox

Configure Travis

Travis uses a simple YAML configuration file. You can configure the test environment there.

.travis.yml

language: node_js
node_js:
  - "0.11"
  - "0.10"

If you decide to test your application in a real browser, you'll have to configure a virtual screen for it using Xvfb:

.travis.yml

language: node_js
node_js:
  - "0.11"
  - "0.10"
before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start

For more information on how to configure a project with Travis, see Building a Node.js project manual.

Configure a test script

Finally, you have to configure npm test command that will be called by Travis after running npm install:

package.json

{
    "name": "...",
    "description": "...",
    "dependencies": {...},
    "scripts": {
        "test": "bender run" // here we add our test command
    }
}

Pro tip: In case you're interested what browsers are available in your test environment, you can use bender run with -l / --list flag before running the actual bender run command:

{
    "name": "...",
    "description": "...",
    "dependencies": {...},
    "scripts": {
        "test": "bender run -l && bender run"
    }
}

This will output a similar list of available browsers:

$ bender run -l

info: [launcher] Available browsers:
local:
- chromium 34.0.1847.116
- firefox 24.5.0
- phantomjs 1.9.7

Clone this wiki locally