1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

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 ```javascript
beforeEach(function() { 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 ```javascript
after(function() { after(function() {
@ -190,4 +192,10 @@ without writing new functions.
``` ```
## How to run the test suite ## 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,21 +3,25 @@
const wd = require('wd'); const wd = require('wd');
const chai = require('chai'); const chai = require('chai');
const chaiAsPromised = require('chai-as-promised'); const chaiAsPromised = require('chai-as-promised');
const config = require('./config.js');
chai.use(chaiAsPromised); chai.use(chaiAsPromised);
chai.should(); chai.should();
describe('Login logs users in', function() {
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); this.timeout(0);
let browser; let browser;
before(function() { before(function() {
browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80); browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80);
return browser.init({ browserName: 'chrome' }); return browser.init({ browserName, version, platform });
}); });
beforeEach(function() { beforeEach(function() {
return browser.get('http://www.ascribe.ninja/app/login'); return browser.get(config.APP_URL + '/login');
}); });
after(function() { after(function() {
@ -28,5 +32,7 @@ describe('Login logs users in', function() {
return browser.title().should.become('Log in'); return browser.title().should.become('Log in');
}); });
}); });
}
config.BROWSERS.map(x => testSuite(...x));