Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
btOptions['view-port'] = '360x640';
if (btOptions.browser === 'chrome') {
const emulation = get(
btOptions,
'chrome.mobileEmulation.deviceName',
'iPhone 6'
);
btOptions.chrome.mobileEmulation = {
deviceName: emulation
};
} else {
btOptions.userAgent = iphone6UserAgent;
}
}
const engine = new browsertime.Engine(btOptions);
const urls = getURLs(parsed.argv._);
await testURLs(engine, urls);
process.exit();
}
}
const scriptCategories = await browserScripts.allScriptCategories;
let scriptsByCategory = await browserScripts.getScriptsForCategories(
scriptCategories
);
if (btOptions.script) {
const userScripts = await parseUserScripts(btOptions.script);
scriptsByCategory = merge(scriptsByCategory, userScripts);
}
if (btOptions.coach) {
scriptsByCategory = addCoachScripts(scriptsByCategory);
}
scriptsByCategory = await addExtraScripts(scriptsByCategory, pluginScripts);
const engine = new browsertime.Engine(btOptions);
const asyncScript =
pluginAsyncScripts.length > 0
? await setupAsynScripts(pluginAsyncScripts)
: undefined;
try {
await engine.start();
if (scriptOrMultiple) {
const res = await engine.runMultiple(
url,
scriptsByCategory,
asyncScript
);
return res;
} else {
async function runBrowsertime(url, script, options) {
function browsertimeify(script) {
return {
coach: {
domAdvice: script
}
};
}
browsertime.logging.configure(options);
options.resultDir = process.cwd();
const engine = new browsertime.Engine(options);
const scripts = await browsertimeify(script);
await engine.start();
try {
return engine.run(url, scripts);
} finally {
engine.stop();
}
}