diff --git a/test/README.md b/test/README.md index 0aab26bd..10b5784c 100644 --- a/test/README.md +++ b/test/README.md @@ -160,7 +160,8 @@ Create the driver to control the browser. }); ``` -This function will be executed before each `it` function. Here we point the browser to a specific URL. +This function will be executed before each `it` function. Here we point the +browser to a specific URL. ```javascript beforeEach(function() { @@ -168,7 +169,8 @@ This function will be executed before each `it` function. Here we point the brow }); ``` -While this function will be executed after each `it` function. `quit` will destroy the browser session. +While this function will be executed after each `it` function. `quit` will +destroy the browser session. ```javascript after(function() { @@ -190,4 +192,10 @@ without writing new functions. ``` ## How to run the test suite +To run the tests, type: +```bash +$ mocha +``` +By default the test suite runs on `http://www.localhost.com:3000/`, if you +want to change the URL, change the `APP_URL` env variable. diff --git a/test/config.js b/test/config.js new file mode 100644 index 00000000..a1ac78db --- /dev/null +++ b/test/config.js @@ -0,0 +1,16 @@ +'use strict'; + + +// https://code.google.com/p/selenium/wiki/DesiredCapabilities +const BROWSERS = [ + 'chrome,47,WINDOWS', + 'chrome,46,WINDOWS', + 'firefox,43,MAC', + 'internet explorer,10,VISTA' +]; + +const APP_URL = process.env.APP_URL || 'http://www.localhost.com:3000'; + + +module.exports.BROWSERS = BROWSERS.map(x => x.split(',')); +module.exports.APP_URL = APP_URL; diff --git a/test/test-login.js b/test/test-login.js index 82bdad9d..0df913ca 100644 --- a/test/test-login.js +++ b/test/test-login.js @@ -3,30 +3,36 @@ const wd = require('wd'); const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); +const config = require('./config.js'); chai.use(chaiAsPromised); chai.should(); -describe('Login logs users in', function() { - this.timeout(0); - let browser; - before(function() { - browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80); - return browser.init({ browserName: 'chrome' }); +function testSuite(browserName, version, platform) { + describe(`[${browserName} ${version} ${platform}] Login logs users in`, function() { + // Set timeout to zero so Mocha won't time out. + this.timeout(0); + let browser; + + before(function() { + browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80); + return browser.init({ browserName, version, platform }); + }); + + beforeEach(function() { + return browser.get(config.APP_URL + '/login'); + }); + + after(function() { + return browser.quit(); + }); + + it('should contain "Log in" in the title', function() { + return browser.title().should.become('Log in'); + }); + }); +} - beforeEach(function() { - return browser.get('http://www.ascribe.ninja/app/login'); - }); - - after(function() { - return browser.quit(); - }); - - it('should contain "Log in" in the title', function() { - return browser.title().should.become('Log in'); - }); - -}); - +config.BROWSERS.map(x => testSuite(...x));