Run Integration Tests using Selenium, Mocha, a Server, and a Browser
These are the goals of grunt-integration
.
- Start a local selenium server instance
- Start a local program, such as
node
application - Wait for the program to listen on a specific port
- Execute integration tests using Mocha and WebDriver
- Using real browsers, such as Chrome
- Automatically, in one command
- Less painful installation process, please!
You'll need node
, java
. If you have apt-get
, you can get java
using the command below. If you like clicking on things, just google for a jdk distribution, and install that.
sudo apt-get install openjdk-7-jdk -y
Then install grunt-integration
from npm
.
npm install --save-dev grunt-integration
Here are the default options
.
Option | Default | Details |
---|---|---|
program |
'node app' |
This will be spawned and expected to listen |
program_port |
process.env.TEST_PORT or 3333 |
Which port will you use? |
program_inherit |
true |
Will program output be printed to the terminal? |
selenium_inherit |
false |
Will selenium server output be printed to the terminal? |
tests |
See below | These are the options passed to mocha |
Here are the default tests
options. Note that if you want to change something in options.tests
, you'll need to replace the whole object, so just copy and paste the defaults, and work from there. That's just how this.options()
works in Grunt at the moment.
tests: {
hostname: '127.0.0.1',
port: 4444,
usePromises: true,
concurrency: 1,
browsers: [{ browserName: 'chrome' }],
timeout: 40000,
reporter: 'spec'
}
You can just configure it like this to get started.
grunt.initConfig({
integration: {
src: ['test/integration/**/*.js']
}
});
For usage examples, you're going to have to sink your teeth in wd.
MIT