protractor-flake
Version:
A wrapper for protractor to automatically re-run failed specs for a specific number of attempts
46 lines • 1.63 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const chalk_1 = require("chalk");
const fs = require("fs");
const DEFAULT_OPTIONS = {
nodeBin: 'node',
maxAttempts: 3,
protractorArgs: [],
color: 'magenta',
parser: 'standard',
};
function parseOptions(providedOptions) {
let options = Object.assign({}, DEFAULT_OPTIONS, providedOptions);
// normalizing options.color to be a boolean or a color value
if (!(options.color in chalk_1.default)) {
if (options.color.toString() === 'false') {
options.color = false;
}
else {
throw new Error('Invalid color option. Color must be one of the supported chalk colors: https://github.com/chalk/ansi-styles#colors');
}
}
if (options.protractorRetryConfig) {
let configPath = path_1.resolve(options.protractorRetryConfig);
try {
fs.lstatSync(configPath).isFile();
options.protractorRetryConfig = configPath;
}
catch (e) {
// do nothing, not a config path
}
}
if (options.protractorPath) {
options.protractorPath = path_1.resolve(options.protractorPath);
}
else {
// '.../node_modules/protractor/lib/protractor.js'
let protractorMainPath = require.resolve('protractor');
// '.../node_modules/protractor/bin/protractor'
options.protractorPath = path_1.resolve(protractorMainPath, '../../bin/protractor');
}
return options;
}
exports.default = parseOptions;
//# sourceMappingURL=parse-options.js.map
;