Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = async function unit(app, options = {}) {
let cwd = process.cwd();
// check sauce values
if (options.saucelabs) {
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME) {
throw 'Missing SAUCE_USERNAME variable.';
}
if (!process.env.SAUCE_ACCESS_KEY) {
throw 'Missing SAUCE_ACCESS_KEY variable.';
}
}
// Handle Karma custom context file option
const customContextFile = options['context'];
module.exports = async function unit(app, options = {}) {
let cwd = process.cwd();
// check sauce values
if (options.saucelabs) {
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME) {
throw 'Missing SAUCE_USERNAME variable.';
}
if (!process.env.SAUCE_ACCESS_KEY) {
throw 'Missing SAUCE_ACCESS_KEY variable.';
}
}
// Handle Karma custom context file option
const customContextFile = options['context'];
if (!process.env.hasOwnProperty('NODE_ENV')) {
.action(async (app, options = {}) => {
const { Project } = require('../../lib/File');
const cwd = process.cwd();
const project = new Project(cwd);
// check sauce values
if (options.saucelabs) {
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME && app.store.get('saucelabs.username')) {
process.env.SAUCE_USERNAME = app.store.get('saucelabs.username');
}
if (!process.env.SAUCE_ACCESS_KEY && app.store.get('saucelabs.accessKey')) {
process.env.SAUCE_ACCESS_KEY = app.store.get('saucelabs.accessKey');
}
if (!process.env.SAUCE_USERNAME) {
throw new Error('missing SAUCE_USERNAME variable');
}
if (!process.env.SAUCE_ACCESS_KEY) {
throw new Error('missing SAUCE_ACCESS_KEY variable');
// override the path
config.test_settings.default.screenshots.path = options.screenshots;
} else {
// set a default path
config.test_settings.default.screenshots.path = config.test_settings.default.screenshots.path || 'reports/e2e/screenshots';
}
} else {
// option.screenshots is false
config.test_settings.default.screenshots = { enabled: false };
}
}
}
let sauceConnectProcess;
if (options.saucelabs) {
// check sauce values
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME) {
app.log(colors.red('Missing SAUCE_USERNAME variable.'));
app.log(colors.grey('export a `SAUCE_USERNAME` environment variable or use the `--saucelabs.username` flag.'));
return global.Promise.reject();
}
if (!process.env.SAUCE_ACCESS_KEY) {
app.log(colors.red('Missing SAUCE_ACCESS_KEY variable.'));
app.log(colors.grey('export a `SAUCE_ACCESS_KEY` environment variable or use the `--saucelabs.key` flag.'));
return global.Promise.reject();
}
promise = promise.then(() => new global.Promise((resolve, reject) => {
.action(async (app, options = {}) => {
const { Project } = require('../../lib/File');
const cwd = process.cwd();
const project = new Project(cwd);
// check sauce values
if (options.saucelabs) {
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME && app.store.get('saucelabs.username')) {
process.env.SAUCE_USERNAME = app.store.get('saucelabs.username');
}
if (!process.env.SAUCE_ACCESS_KEY && app.store.get('saucelabs.accessKey')) {
process.env.SAUCE_ACCESS_KEY = app.store.get('saucelabs.accessKey');
}
if (!process.env.SAUCE_USERNAME) {
throw new Error('missing SAUCE_USERNAME variable');
}
if (!process.env.SAUCE_ACCESS_KEY) {
throw new Error('missing SAUCE_ACCESS_KEY variable');
}
config.test_settings.default.screenshots.path = options.screenshots;
} else {
// set a default path
config.test_settings.default.screenshots.path = config.test_settings.default.screenshots.path || 'reports/e2e/screenshots';
}
} else {
// option.screenshots is false
config.test_settings.default.screenshots = { enabled: false };
}
}
}
let sauceConnectProcess;
if (options.saucelabs) {
// check sauce values
if (options['saucelabs.username']) {
process.env.SAUCE_USERNAME = options['saucelabs.username'];
}
if (options['saucelabs.key']) {
process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
}
if (!process.env.SAUCE_USERNAME) {
app.log(colors.red('Missing SAUCE_USERNAME variable.'));
app.log(colors.grey('export a `SAUCE_USERNAME` environment variable or use the `--saucelabs.username` flag.'));
return global.Promise.reject();
}
if (!process.env.SAUCE_ACCESS_KEY) {
app.log(colors.red('Missing SAUCE_ACCESS_KEY variable.'));
app.log(colors.grey('export a `SAUCE_ACCESS_KEY` environment variable or use the `--saucelabs.key` flag.'));
return global.Promise.reject();
}
promise = promise.then(() => new global.Promise((resolve, reject) => {
// setup sauce connect for localhost tunnel