garris / garris/BackstopJS

Allow to set scenario option defaults globally

Open
#1,432 6 comments 6 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.2k
Forks
621
PR merge metrics
No merged PRs in 30d

Description

**Context:**
Quite often some of the [advanced scenario settings](https://github.com/garris/BackstopJS#advanced-scenarios) apply to every scenario and are "global".
For example the `hideSelectors` are the same for each scenario, e.g. for Cookie Banners, Sliders, ... or you need a delay on each scenario, ...

**Problem**
BackstopJS doesn't yet allow to set defaults for these scenario settings at the global level.

There are several issues already, asking for single scenario settings to be set globally, like
- https://github.com/garris/BackstopJS/issues/1309
- https://github.com/garris/BackstopJS/issues/1090
- https://github.com/garris/BackstopJS/issues/715

Expected behavior would be that a scenario uses
a) The BackstopJS predefined defaults, if no global default is set
b) The global default if it is set and not overridden in the current scenario
c) The current scenario setting, if it is set (and thereby overriding all global settings)

**Proposed solution:**
Allow to define scenario setting defaults at the global level.
I think it would be totally fine, if the global level just uses the same keys. For example set `delay` just like `debug`. If we fear clashing variables, these could be put below a parent setting like `scenarioDefaults: {}` but I don't think that's needed.

There is already one scenario setting which allows this:
`viewports // An array of screen size objects your DOM will be tested against. This configuration will override the viewports property assigned at the config root.`

It would be great, if that could be the same for all scenario settings!

This feature would really help a lot to safe duplicate code, a lot of time and potential copy / paste errors. It would make the configuration json a lot smarter.

Thank you very much for this great great project!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.