mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
Add multi browser test
This commit is contained in:
parent
d20c6baae6
commit
a95a0fd2ea
@ -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
16
test/config.js
Normal 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;
|
@ -3,30 +3,36 @@
|
|||||||
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() {
|
|
||||||
this.timeout(0);
|
|
||||||
let browser;
|
|
||||||
|
|
||||||
before(function() {
|
function testSuite(browserName, version, platform) {
|
||||||
browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80);
|
describe(`[${browserName} ${version} ${platform}] Login logs users in`, function() {
|
||||||
return browser.init({ browserName: 'chrome' });
|
// 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() {
|
config.BROWSERS.map(x => testSuite(...x));
|
||||||
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');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user