Add multi browser test

This commit is contained in:
vrde 2016-01-22 17:52:03 +01:00
parent d20c6baae6
commit a95a0fd2ea
3 changed files with 52 additions and 22 deletions

View File

@ -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.

16
test/config.js Normal file
View File

@ -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;

View File

@ -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));