mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 01:13:14 +01:00
Add utils to manage tunnel and stuff
This commit is contained in:
parent
a95a0fd2ea
commit
778c61bfdc
@ -1,2 +1,3 @@
|
||||
SAUCE_USERNAME=ascribe
|
||||
SAUCE_ACCESS_KEY=
|
||||
SAUCE_DEFAULT_URL=
|
||||
|
@ -11,7 +11,9 @@
|
||||
"preinstall": "export SAUCE_CONNECT_DOWNLOAD_ON_INSTALL=true",
|
||||
"postinstall": "npm run build",
|
||||
"build": "gulp build --production",
|
||||
"start": "node server.js"
|
||||
"start": "node server.js",
|
||||
"test": "mocha",
|
||||
"tunnel": "node test/tunnel.js"
|
||||
},
|
||||
"browser": {
|
||||
"fineUploader": "./js/components/ascribe_uploader/vendor/s3.fine-uploader.js"
|
||||
@ -38,6 +40,7 @@
|
||||
"babel-jest": "^5.2.0",
|
||||
"chai": "^3.4.1",
|
||||
"chai-as-promised": "^5.1.0",
|
||||
"colors": "^1.1.2",
|
||||
"dotenv": "^1.2.0",
|
||||
"gulp-sass": "^2.1.1",
|
||||
"jest-cli": "^0.4.0",
|
||||
|
@ -1,3 +1,13 @@
|
||||
# TL;DR
|
||||
Copy the file `.env-template` in `.env` and fill up the missing keys.
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm run tunnel
|
||||
$ npm test && git commit
|
||||
```
|
||||
|
||||
|
||||
# Welcome to our test suite, let me be your guide
|
||||
|
||||
Dear reader, first of all thanks for taking your time reading this document.
|
||||
@ -199,3 +209,10 @@ $ 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.
|
||||
|
||||
|
||||
# How to have fun
|
||||
Try this!
|
||||
```bash
|
||||
$ mocha -R nyan
|
||||
```
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
require('dotenv').load();
|
||||
|
||||
|
||||
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
|
||||
const BROWSERS = [
|
||||
@ -9,8 +11,9 @@ const BROWSERS = [
|
||||
'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;
|
||||
module.exports = {
|
||||
BROWSERS: BROWSERS.map(x => x.split(',')),
|
||||
APP_URL: process.env.SAUCE_DEFAULT_URL || 'http://www.localhost.com:3000',
|
||||
TUNNEL_AUTO_CONNECT: process.env.SAUCE_AUTO_CONNECT
|
||||
};
|
||||
|
@ -1,14 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
require('dotenv').load();
|
||||
|
||||
const config = require('./config');
|
||||
const colors = require('colors');
|
||||
const sauceConnectLauncher = require('sauce-connect-launcher');
|
||||
|
||||
|
||||
let globalSauceProcess;
|
||||
|
||||
if (!process.env.SAUCE_USERNAME) {
|
||||
console.log(colors.red('SAUCE_USERNAME is missing. Please check the README.md file.'));
|
||||
process.exit(1); //eslint-disable-line no-process-exit
|
||||
}
|
||||
|
||||
if (process.env.SAUCE_AUTO_CONNECT) {
|
||||
if (!process.env.SAUCE_ACCESS_KEY2) {
|
||||
console.log(colors.red('SAUCE_ACCESS_KEY is missing. Please check the README.md file.'));
|
||||
process.exit(1); //eslint-disable-line no-process-exit
|
||||
}
|
||||
|
||||
|
||||
if (config.TUNNEL_AUTO_CONNECT) {
|
||||
before(function(done) {
|
||||
// Creating the tunnel takes a bit of time. For this case we can safely disable it.
|
||||
console.log(colors.yellow('Setting up tunnel from Saucelabs to your lovely computer, will take a while.'));
|
||||
// Creating the tunnel takes a bit of time. For this case we can safely disable Mocha timeouts.
|
||||
this.timeout(0);
|
||||
|
||||
sauceConnectLauncher(function (err, sauceConnectProcess) {
|
||||
@ -30,4 +43,8 @@ if (process.env.SAUCE_AUTO_CONNECT) {
|
||||
globalSauceProcess.close(done);
|
||||
}
|
||||
});
|
||||
} else if (config.APP_URL.match(/localhost/)) {
|
||||
console.log(colors.yellow(`You are running tests on ${config.APP_URL}, make sure you already have a tunnel running.`));
|
||||
console.log(colors.yellow('To create the tunnel, run:'));
|
||||
console.log(colors.yellow(' $ node test/tunnel.js'));
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ function testSuite(browserName, version, platform) {
|
||||
let browser;
|
||||
|
||||
before(function() {
|
||||
// No need to inject `username` or `access_key`, by default the constructor
|
||||
// looks up the values in `process.env.SAUCE_USERNAME` and `process.env.SAUCE_ACCESS_KEY`
|
||||
browser = wd.promiseChainRemote('ondemand.saucelabs.com', 80);
|
||||
return browser.init({ browserName, version, platform });
|
||||
});
|
||||
|
23
test/tunnel.js
Normal file
23
test/tunnel.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('./config'); //eslint-disable-line no-unused-vars
|
||||
const colors = require('colors');
|
||||
const sauceConnectLauncher = require('sauce-connect-launcher');
|
||||
|
||||
|
||||
function connect() {
|
||||
console.log(colors.yellow('Setting up tunnel from Saucelabs to your lovely computer, will take a while.'));
|
||||
// Creating the tunnel takes a bit of time. For this case we can safely disable Mocha timeouts.
|
||||
|
||||
sauceConnectLauncher(function (err) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
return;
|
||||
}
|
||||
console.log(colors.green('Connected! Keep this process running and execute your tests.'));
|
||||
});
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
connect();
|
||||
}
|
Loading…
Reference in New Issue
Block a user