api
stranger provides a simple api for configuration, the cli tool, and for programmatic usage.
Configuration
-
baseDir
- Required string. This is the path where the base set of images should be saved to.
-
compareDir
- Required string. This is the path where the set of images to be compared should be saved to.
-
diffDir
- Required string. This is the path where any diff images should be saved to.
-
browser
- Optional string. The browser to be used for screenshots.Can be chrome, firefox, safari, ie, or opera. Defaults to firefox.
-
browserOptions
- Optional object. Options to be set in here configure the viewport of the browser taking screenshots.
-
browserOptions.width
- Optional number. The width of the viewport in pixels. Defaults to 1024.
-
browserOptions.height
- Optional number. The height of the viewport in pixels. Defaults to 768.
-
chromeOptions
- Optional object. Refer to the selenium docs for details.
-
firefoxOptions
- Optional object. Refer to the selenium docs for details.
-
ieOptions
- Optional object. Refer to the selenium docs for details.
-
operaOptions
- Optional object. Refer to the selenium docs for details
-
safariOptions
- Optional object. Refer to the selenium docs for details
-
tests
- Required array of test objects. This list of tests produces the screenshots and determine which images to compare.
-
test.url
- Required string. The URL to take the screenshot of. If this is a local file, either add the
file://
protocol, or set local to true.
-
test.name
- Optional string. The filename for the screenshot. If missing, the last part of the path name will be used.
-
test.local
- Optional boolean. If set to true, stranger forces the
file://
protocol. Defaults to false.
CLI
$ stranger [options]
-
--config, -c
- Required path. The path to the configuration file to use.
-
--generate, -g
- Optional. Whether to generate the base images or not.
-
--help, -h
- Optional. Print the help text.
Programmatic usage
vr(config, generate, callback);
-
config
- Required string. The path to the configuration file to use.
-
generate
- Required boolean. Whether or not to generate the base set of images.
-
callback
- Optional function. The function to run when the tool has finished diffing the images. An object will be passed back containing details of the results.