Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ config.js
diff.js
diverged.js
divergedWorker.js
**/examples/**
**/old_splash_page_v2.0/**
**/dist/**
**/angular.min.js
**/js/vendor/**
8 changes: 4 additions & 4 deletions capture/backstopTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = (target) => {
if (typeof window._backstopTools._consoleLogger !== 'string') {
window._backstopTools._consoleLogger = '';
}
var log = window.console.log.bind(console);
const log = window.console.log.bind(console);
window.console.log = function () {
window._backstopTools._consoleLogger += Array.from(arguments).join('\n');
log.apply(this, arguments);
Expand All @@ -38,14 +38,14 @@ module.exports = (target) => {
if (selector === 'document') {
return acc.concat(['document']);
}
var qResult = document.querySelectorAll(selector);
const qResult = document.querySelectorAll(selector);

// pass-through any selectors that don't match any DOM elements
if (!qResult.length) {
return acc.concat(selector);
}

var expandedSelector = [].slice.call(qResult)
const expandedSelector = [].slice.call(qResult)
.map(function (element, expandedIndex) {
if (element.classList.contains('__86d')) {
return '';
Expand All @@ -56,7 +56,7 @@ module.exports = (target) => {
return selector;
}
// create index partial
var indexPartial = '__n' + expandedIndex;
const indexPartial = '__n' + expandedIndex;
// update all matching selectors with additional indexPartial class
element.classList.add(indexPartial);
// return array of fully-qualified classnames
Expand Down
12 changes: 6 additions & 6 deletions cli/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env node

var parseArgs = require('minimist');
var usage = require('./usage');
var version = require('../package.json').version;
var runner = require('../core/runner');
const parseArgs = require('minimist');
const usage = require('./usage');
const version = require('../package.json').version;
const runner = require('../core/runner');

main();

function main () {
var argsOptions = parseArgs(process.argv.slice(2), {
const argsOptions = parseArgs(process.argv.slice(2), {
boolean: ['h', 'help', 'v', 'version', 'i', 'docker'],
string: ['config'],
default: {
Expand All @@ -31,7 +31,7 @@ function main () {
return;
}

var commandName = argsOptions['_'][0];
const commandName = argsOptions['_'][0];

if (!commandName) {
console.log(usage);
Expand Down
20 changes: 10 additions & 10 deletions cli/usage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var version = require('../package.json').version;
var makeSpaces = require('../core/util/makeSpaces');
const version = require('../package.json').version;
const makeSpaces = require('../core/util/makeSpaces');

var commandsDescription = {
const commandsDescription = {
test: 'Create test screenshots and compare against the set you previously approved/referenced.',
approve: 'Promotes all test bitmaps from last test run to reference bitmaps.',
reference: 'Creates new reference screenshots. Deletes all existing reference files.',
Expand All @@ -10,7 +10,7 @@ var commandsDescription = {
openReport: 'View the last test report in your browser.'
};

var optionsDescription = {
const optionsDescription = {
'--config': 'Path to config file name',
'--filter': 'A RegEx string used to filter by scenario labels when running "test", "reference", or "approve" commands',
'-h, --help': 'Display usage',
Expand All @@ -26,12 +26,8 @@ function makeDescription (descriptions) {
.join('\n');
}

function spacesBetweenCommandAndDescription (commandName) {
return makeSpaces(2 + leftPaddingOfDescription - commandName.length);
}

// Number of spaces to echo before writing description
var leftPaddingOfDescription = Object.keys(commandsDescription)
const leftPaddingOfDescription = Object.keys(commandsDescription)
.concat(Object.keys(optionsDescription))
.map(function (string) {
return string.length;
Expand All @@ -40,7 +36,11 @@ var leftPaddingOfDescription = Object.keys(commandsDescription)
return Math.max(max, length);
}, 0);

var usage = '\
function spacesBetweenCommandAndDescription (commandName) {
return makeSpaces(2 + leftPaddingOfDescription - commandName.length);
}

const usage = '\
Welcome to BackstopJS ' + version + ' CLI\n\
\n\
Commands:\n\
Expand Down
12 changes: 6 additions & 6 deletions core/command/approve.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var fs = require('../util/fs');
var path = require('path');
var map = require('p-map');
const fs = require('../util/fs');
const path = require('path');
const map = require('p-map');

var FAILED_DIFF_RE = /^failed_diff_/;
var FILTER_DEFAULT = /\w+/;
const FAILED_DIFF_RE = /^failed_diff_/;
const FILTER_DEFAULT = /\w+/;

// This task will copy ALL test bitmap files (from the most recent test directory) to the reference directory overwriting any existing files.
module.exports = {
Expand All @@ -16,7 +16,7 @@ module.exports = {
console.log(err.stack);
reject(err);
}
var src = path.join(config.bitmaps_test, list[list.length - 1]);
const src = path.join(config.bitmaps_test, list[list.length - 1]);
return fs.readdir(src, (err, files) => {
if (err) {
console.log(err.stack);
Expand Down
18 changes: 9 additions & 9 deletions core/command/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var path = require('path');
var logger = require('../util/logger')('COMMAND');
const path = require('path');
const logger = require('../util/logger')('COMMAND');

/*
* Each file included in this folder (except `index.js`) is a command and must export the following object
Expand All @@ -11,7 +11,7 @@ var logger = require('../util/logger')('COMMAND');
*/

/* Each and every command defined, including commands used in before/after */
var commandNames = [
const commandNames = [
'init',
'remote',
'openReport',
Expand All @@ -24,7 +24,7 @@ var commandNames = [
];

/* Commands that are only exposed to higher levels */
var exposedCommandNames = [
const exposedCommandNames = [
'init',
'remote',
'reference',
Expand All @@ -41,7 +41,7 @@ function toObjectReducer (object, command) {
return object;
}

var commands = commandNames
const commands = commandNames
.map(function requireCommand (commandName) {
return {
name: commandName,
Expand All @@ -55,7 +55,7 @@ var commands = commandNames
config.perf[command.name] = { started: new Date() };
logger.info('Executing core for "' + command.name + '"');

var promise = command.commandDefinition.execute(config);
let promise = command.commandDefinition.execute(config);

// If the command didn't return a promise, assume it resolved already
if (!promise) {
Expand All @@ -66,7 +66,7 @@ var commands = commandNames
// Do the catch separately or the main runner
// won't be able to catch it a second time
promise.catch(function (error) {
var perf = (new Date() - config.perf[command.name].started) / 1000;
const perf = (new Date() - config.perf[command.name].started) / 1000;
logger.error('Command "' + command.name + '" ended with an error after [' + perf + 's]');
logger.error(error);
});
Expand All @@ -75,7 +75,7 @@ var commands = commandNames
if (/openReport/.test(command.name)) {
return;
}
var perf = (new Date() - config.perf[command.name].started) / 1000;
const perf = (new Date() - config.perf[command.name].started) / 1000;
logger.success('Command "' + command.name + '" successfully executed in [' + perf + 's]');
return result;
});
Expand All @@ -84,7 +84,7 @@ var commands = commandNames
})
.reduce(toObjectReducer, {});

var exposedCommands = exposedCommandNames
const exposedCommands = exposedCommandNames
.filter(function commandIsDefined (commandName) {
return commands.hasOwnProperty(commandName);
})
Expand Down
6 changes: 3 additions & 3 deletions core/command/init.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var fs = require('../util/fs');
var logger = require('../util/logger')('init');
const fs = require('../util/fs');
const logger = require('../util/logger')('init');

/**
* Copies a boilerplate config file to the current config file location.
*/
module.exports = {
execute: function init (config) {
var promises = [];
const promises = [];
if (config.engine_scripts) {
logger.log("Copying '" + config.engine_scripts_default + "' to '" + config.engine_scripts + "'");
promises.push(fs.copy(config.engine_scripts_default, config.engine_scripts));
Expand Down
2 changes: 1 addition & 1 deletion core/command/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
if (shouldRunDocker(config)) {
return runDocker(config, 'reference');
} else {
var firstStep;
let firstStep;
// do not remove reference directory if we are in incremental mode
if (config.args.filter || config.args.i) {
firstStep = Promise.resolve();
Expand Down
Loading