If you don't already have a BackstopJS config file. The following command will create a config template file which you can modify in your root directory. Note: this will overwrite any existing backstopjs config file.
From ./node_modules/backstopjs
…
$ gulp genConfig
This will generate a boilerplate JSON configuration file for you at the root of your project e.g. greenwire-styleguide/source/backstop.json
. This is where you can specify the URL's, selectors to test and at which breakpoints you want to test them at.
{
"viewports": [
{
"name": "phone",
"width": 320,
"height": 480
}, {
"name": "tablet_small",
"width": 480,
"height": 768
}, {
"name": "tablet",
"width": 768,
"height": 1024
}, {
"name": "desktop",
"width": 1024,
"height": 768
}
],
"scenarios": [
{
"label": "Forms",
"url": "http://ggw-prototype.goalgorilla.com/components/forms.html",
"selectors": [
"#test-basic-form",
"#test-horizontal-form"
],
"readyEvent": "domready",
"delay": 500
}
]
}
In this configuration you can see three viewports objects, one for phone, one for small tablets, one for iPad tablet landscape and one for desktop, each with a name and a viewport property. You can add as many viewports objects as you need. BackstopJS requires at least one.
Then we have scenarios. This specifies the URLs and element selectors that BackstopJS will test. The selectors generally accept standard CSS selector notation. It's useful to think of every scenario as a test for a specific static page. Here too, you can add as many scenarios as you need. BackstopJS requires at least one.
You may notice that in this config, our URL is pointing to http://ggw-prototype.goalgorilla.com/ (the form page of the UI component library) and that is what we would see if we were to run our test now. This is here to illustrate that BackstopJS can point to local or remote URLs so it's easy to imagine repurposing the same tests for local development, QA, staging and production environments.