Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to read config settings from onBefore script. #994

Merged
merged 6 commits into from
Mar 11, 2019
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@ By default the base path is a folder called `engine_scripts` inside your Backsto
}
```

#### onBeforeScript/onReadyScript available variables

onBefore(engine, scenario, viewport, isReference, Engine, config)

```
engine: chromy or puppetter engine instance
scenario: currently running scenario config
viewport: viewport info
isReference: whether scenario contains reference URL propery
Engine: Static class reference (Chromy or Puppeteer)
config: the whole config object
```

### Reporting workflow tips

Expand Down
4 changes: 2 additions & 2 deletions core/util/runChromy.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function processScenarioView (scenario, variantOrScenarioLabelSafe, scenarioLabe
if (onBeforeScript) {
var beforeScriptPath = path.resolve(engineScriptsPath, onBeforeScript);
if (fs.existsSync(beforeScriptPath)) {
require(beforeScriptPath)(chromy, scenario, viewport, isReference, Chromy);
require(beforeScriptPath)(chromy, scenario, viewport, isReference, Chromy, config);
} else {
console.warn(PORT, ' WARNING: script not found: ' + beforeScriptPath);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ function processScenarioView (scenario, variantOrScenarioLabelSafe, scenarioLabe
if (onReadyScript) {
var readyScriptPath = path.resolve(engineScriptsPath, onReadyScript);
if (fs.existsSync(readyScriptPath)) {
require(readyScriptPath)(chromy, scenario, viewport, isReference, Chromy);
require(readyScriptPath)(chromy, scenario, viewport, isReference, Chromy, config);
} else {
console.warn(PORT, 'WARNING: script not found: ' + readyScriptPath);
}
Expand Down
4 changes: 2 additions & 2 deletions core/util/runPuppet.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async function processScenarioView (scenario, variantOrScenarioLabelSafe, scenar
if (onBeforeScript) {
var beforeScriptPath = path.resolve(engineScriptsPath, onBeforeScript);
if (fs.existsSync(beforeScriptPath)) {
await require(beforeScriptPath)(page, scenario, viewport, isReference, browser);
await require(beforeScriptPath)(page, scenario, viewport, isReference, browser, config);
} else {
console.warn('WARNING: script not found: ' + beforeScriptPath);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ async function processScenarioView (scenario, variantOrScenarioLabelSafe, scenar
if (onReadyScript) {
var readyScriptPath = path.resolve(engineScriptsPath, onReadyScript);
if (fs.existsSync(readyScriptPath)) {
await require(readyScriptPath)(page, scenario, viewport, isReference, browser);
await require(readyScriptPath)(page, scenario, viewport, isReference, browser, config);
} else {
console.warn('WARNING: script not found: ' + readyScriptPath);
}
Expand Down