How to use getEngineOption method in backstopjs

Best JavaScript code snippet using backstopjs

engineTools.js

Source:engineTools.js Github

copy

Full Screen

1function getMisMatchThreshHold (scenario, config) {2 if (typeof scenario.misMatchThreshold !== 'undefined') { return scenario.misMatchThreshold; }3 if (typeof config.misMatchThreshold !== 'undefined') { return config.misMatchThreshold; }4 return config.defaultMisMatchThreshold;5}6function ensureFileSuffix (filename, suffix) {7 var re = new RegExp('\.' + suffix + '$', ''); // eslint-disable-line no-useless-escape8 return filename.replace(re, '') + '.' + suffix;9}10// merge both strings while soft-enforcing a single slash between them11function glueStringsWithSlash (stringA, stringB) {12 return stringA.replace(/\/$/, '') + '/' + stringB.replace(/^\//, '');13}14function genHash (str) {15 var hash = 0;16 var i;17 var chr;18 var len;19 if (!str) return hash;20 str = str.toString();21 for (i = 0, len = str.length; i < len; i++) {22 chr = str.charCodeAt(i);23 hash = ((hash << 5) - hash) + chr;24 hash |= 0; // Convert to 32bit integer25 }26 // return a string and replace a negative sign with a zero27 return hash.toString().replace(/^-/, 0);28}29function getRequireSameDimentions (scenario, config) {30 if (scenario.requireSameDimensions !== undefined) {31 return scenario.requireSameDimensions;32 } else if (config.requireSameDimensions !== undefined) {33 return config.requireSameDimensions;34 } else {35 return config.defaultRequireSameDimensions;36 }37}38function getSelectorName (selector) {39 return selector.replace(/[^a-z0-9_-]/gi, ''); // remove anything that's not a letter or a number40}41function makeSafe (str) {42 return str.replace(/[ /]/g, '_');43}44function getFilename (fileNameTemplate, outputFileFormatSuffix, configId, scenarioIndex, scenarioLabelSafe, selectorIndex, selectorLabel, viewportIndex, viewportLabel) {45 var fileName = fileNameTemplate46 .replace(/\{configId\}/, configId)47 .replace(/\{scenarioIndex\}/, scenarioIndex)48 .replace(/\{scenarioLabel\}/, scenarioLabelSafe)49 .replace(/\{selectorIndex\}/, selectorIndex)50 .replace(/\{selectorLabel\}/, selectorLabel)51 .replace(/\{viewportIndex\}/, viewportIndex)52 .replace(/\{viewportLabel\}/, makeSafe(viewportLabel))53 .replace(/[^a-z0-9_-]/gi, ''); // remove anything that's not a letter or a number or dash or underscore.54 var extRegExp = new RegExp(outputFileFormatSuffix + '$', 'i');55 if (!extRegExp.test(fileName)) {56 fileName = fileName + outputFileFormatSuffix;57 }58 return fileName;59}60function getEngineOption (config, optionName, fallBack) {61 if (typeof config.engineOptions === 'object' && config.engineOptions[optionName]) {62 return config.engineOptions[optionName];63 }64 return fallBack;65}66function getScenarioExpect (scenario) {67 let expect = 0;68 if (scenario.selectorExpansion && scenario.selectors && scenario.selectors.length && scenario.expect) {69 expect = scenario.expect;70 }71 return expect;72}73function generateTestPair (config, scenario, viewport, variantOrScenarioLabelSafe, scenarioLabelSafe, selectorIndex, selector) {74 const cleanedSelectorName = getSelectorName(selector);75 const fileName = getFilename(76 config._fileNameTemplate,77 config._outputFileFormatSuffix,78 config._configId,79 scenario.sIndex,80 variantOrScenarioLabelSafe,81 selectorIndex,82 cleanedSelectorName,83 viewport.vIndex,84 viewport.label85 );86 const referenceFilePath = config._bitmapsReferencePath + '/' + getFilename(87 config._fileNameTemplate,88 config._outputFileFormatSuffix,89 config._configId,90 scenario.sIndex,91 scenarioLabelSafe,92 selectorIndex,93 cleanedSelectorName,94 viewport.vIndex,95 viewport.label96 );97 const testFilePath = config._bitmapsTestPath + '/' + config.screenshotDateTime + '/' + fileName;98 return {99 reference: referenceFilePath,100 test: testFilePath,101 selector: selector,102 fileName: fileName,103 label: scenario.label,104 requireSameDimensions: getRequireSameDimentions(scenario, config),105 misMatchThreshold: getMisMatchThreshHold(scenario, config),106 url: scenario.url,107 referenceUrl: scenario.referenceUrl,108 expect: getScenarioExpect(scenario),109 viewportLabel: viewport.label110 };111}112module.exports = {113 generateTestPair: generateTestPair,114 getMisMatchThreshHold: getMisMatchThreshHold,115 getRequireSameDimentions: getRequireSameDimentions,116 ensureFileSuffix: ensureFileSuffix,117 glueStringsWithSlash: glueStringsWithSlash,118 genHash: genHash,119 makeSafe: makeSafe,120 getFilename: getFilename,121 getEngineOption: getEngineOption,122 getSelectorName: getSelectorName,123 getScenarioExpect: getScenarioExpect...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var backstop = require('backstopjs');2var config = require('./backstop.json');3var engine = require('puppeteer');4var options = {5 engineOptions: {6 }7};8backstop('test', {config: config, engineOptions: options});9* [BackstopJS](

Full Screen

Using AI Code Generation

copy

Full Screen

1var engine = require('backstopjs');2engine.getEngineOption('casperFlags', function(err, casperFlags) {3 console.log(casperFlags);4});5{ '--ignore-ssl-errors': 'yes',6 '--local-to-remote-url-access': 'true' }

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run backstopjs automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful