diff --git a/README.md b/README.md index 4214da4be..e51ca5606 100644 --- a/README.md +++ b/README.md @@ -529,6 +529,21 @@ An example config below... } ``` +### Using Chromy static functions +To access use of Chromys static functions (such as addCustomDevice) the static chromy reference is sent as the fifth parameter to your onBefore/onReady scripts. + +Example usage: + +``` +module.exports = function (chromy, scenario, vp, isReference, chromyStatic) { + if(vp.label === "phone") { + chromyStatic.addCustomDevice({ name: "some-phone", /.../ }); + chromy.emulate("some-phone"); + } +} +``` +For more info, see the [Chromy script documentation](https://github.com/OnetapInc/chromy). + ### Integration options (local install) TLDR; run the example here... diff --git a/core/command/index.js b/core/command/index.js index dd85e38f6..0e1c89dab 100644 --- a/core/command/index.js +++ b/core/command/index.js @@ -62,7 +62,7 @@ var commands = commandNames promise.catch(function (error) { var perf = (new Date() - config.perf[command.name].started) / 1000; logger.error('Command `' + command.name + '` ended with an error after [' + perf + 's]'); - // logger.error(error); + logger.error(error); }); return promise.then(function (result) { diff --git a/core/util/runChromy.js b/core/util/runChromy.js index 2a6c88526..f872cec88 100644 --- a/core/util/runChromy.js +++ b/core/util/runChromy.js @@ -27,6 +27,7 @@ module.exports = function (args) { const runId = args.id; const scenarioLabelSafe = makeSafe(scenario.label); const variantOrScenarioLabelSafe = scenario._parent ? makeSafe(scenario._parent.label) : scenarioLabelSafe; + return processScenarioView(scenario, variantOrScenarioLabelSafe, scenarioLabelSafe, viewport, config, runId); }; @@ -171,7 +172,7 @@ function processScenarioView (scenario, variantOrScenarioLabelSafe, scenarioLabe if (onBeforeScript) { var beforeScriptPath = path.resolve(engineScriptsPath, onBeforeScript); if (fs.existsSync(beforeScriptPath)) { - require(beforeScriptPath)(chromy, scenario, viewport, isReference); + require(beforeScriptPath)(chromy, scenario, viewport, isReference, Chromy); } else { console.warn(PORT, ' WARNING: script not found: ' + beforeScriptPath); } @@ -246,7 +247,7 @@ function processScenarioView (scenario, variantOrScenarioLabelSafe, scenarioLabe if (onReadyScript) { var readyScriptPath = path.resolve(engineScriptsPath, onReadyScript); if (fs.existsSync(readyScriptPath)) { - require(readyScriptPath)(chromy, scenario, viewport, isReference); + require(readyScriptPath)(chromy, scenario, viewport, isReference, Chromy); } else { console.warn(PORT, 'WARNING: script not found: ' + readyScriptPath); }