1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/test/setup.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-12-19 17:40:53 +01:00
'use strict';
2016-01-25 11:05:01 +01:00
const config = require('./config');
const colors = require('colors');
2015-12-19 17:40:53 +01:00
const sauceConnectLauncher = require('sauce-connect-launcher');
2016-01-25 11:05:01 +01:00
2015-12-19 17:40:53 +01:00
let globalSauceProcess;
2016-01-25 11:05:01 +01:00
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
}
2016-01-25 11:24:35 +01:00
if (!process.env.SAUCE_ACCESS_KEY) {
2016-01-25 11:05:01 +01:00
console.log(colors.red('SAUCE_ACCESS_KEY is missing. Please check the README.md file.'));
process.exit(1); //eslint-disable-line no-process-exit
}
2015-12-19 17:40:53 +01:00
2016-01-25 11:32:43 +01:00
if (process.env.SAUCE_AUTO_CONNECT) {
2015-12-19 17:40:53 +01:00
before(function(done) {
2016-01-25 11:05:01 +01:00
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.
2015-12-19 17:40:53 +01:00
this.timeout(0);
sauceConnectLauncher(function (err, sauceConnectProcess) {
if (err) {
console.error(err.message);
return;
}
globalSauceProcess = sauceConnectProcess;
done();
});
});
after(function (done) {
// Creating the tunnel takes a bit of time. For this case we can safely disable it.
this.timeout(0);
if (globalSauceProcess) {
globalSauceProcess.close(done);
}
});
2016-01-25 11:05:01 +01:00
} 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'));
2015-12-19 17:40:53 +01:00
}