Configuration
The test config files (**.osnap.json
by default), are used to specify a single test to be executed on all defaultSizes
. A test file consists of an array of tests with the following possible options:
Options
Name
- Key:
name
- Required:
true
- Type:
string
The name of the test.
This has to be unique, as it will be used to name the base image of this snapshot.
Url
- Key:
url
- Required:
true
- Type:
string
The url (concatenated with the baseUrl
) to screenshot.
Only
- Key:
only
- Required:
false
- Type:
boolean (true / false)
- Default:
false
If set to true
, OSnap will only run tests with only
set to true and skip all other tests.
If OSnap runs with the --no-only
cli flag, having this set to true
will fail the test run.
Skip
- Key:
skip
- Required:
false
- Type:
boolean (true / false)
- Default:
false
If set to true
, this test will be skipped.
If OSnap runs with the --no-skip
cli flag, having this set to true
will fail the test run.
Threshold
- Key:
threshold
- Required:
false
- Type:
int
- Default: Whatever is specified in the global threshold
The number of pixels allowed to be different, before the test will be marked as failed.
Ignore Regions
- Key:
ignore
- Required:
false
- Type:
Array<region>
- Default:
[]
An array of regions to ignore in your screenshot.
For possible options and more info refer to: ignore regions.
Actions
- Key:
actions
- Required:
false
- Type:
Array<action>
- Default:
[]
An array of actions to run before the screenshot is taken.
For possible options and more info refer to: actions.
Example
The smallest possible test file would look like this:
- YAML
- JSON
- name: Login
url: "/path/to/login.html"
[
{
"name": "Login",
"url": "/path/to/login.html"
}
]
A full example of a test file:
- YAML
- JSON
- name: Home
url: "/"
threshold: 20
sizes:
- name: xl
width: 1600
height: 768
- name: xs
width: 768
height: 1024
- name: xxs
width: 320
height: 500
ignore:
- "@": ["xxs"]
x1: 0
y1: 0
x2: 100
y2: 100
- selector: ".my-animation"
actions:
- action: type
selector: "#search"
text: some text to type
- action: click
selector: "#id .class"
- "@": ["xxs", "xs"]
action: wait
timeout: 2000
[
{
"name": "Home",
"url": "/",
"threshold": 20,
"sizes": [
{
"name": "xl",
"width": 1600,
"height": 768
},
{
"name": "xs",
"width": 768,
"height": 1024
},
{
"name": "xxs",
"width": 320,
"height": 500
}
],
"ignore": [
{
"@": ["xxs"],
"x1": 0,
"y1": 0,
"x2": 100,
"y2": 100
},
{
"selector": ".my-animation"
}
],
"actions": [
{
"action": "type",
"selector": "#search",
"text": "some text to type"
},
{
"action": "click",
"selector": "#id .class"
},
{
"@": ["xxs", "xs"],
"action": "wait",
"timeout": 2000
}
]
}
]