phantomcss-kit
v0.2.5
Published
A quick way to set up visual regression testing with PhantomCSS
Downloads
4
Readme
phantomcss-kit
This NPM utility library provides a quick way to run a pre-defined PhantomCSS test suite against your web page.
Requirements
- Python is required to run CasperJS.
Usage
- Install:
npm i phantomcss-kit --save-dev
- Create a page you would like run the tests against. Mark the elements to test using the
pk-test
attribute:
<div pk-test="first">Hello!</div>
The value of pk-test
will be used as the name of the test case.
- Run the tests:
pk-test --url=%ABSOLUTE_PAGE_URL%
Generating test cases
To generate new test cases, use the --rebase
flag:
pk-test --url=%ABSOLUTE_PAGE_URL% --rebase
Running a local web server
If you don't have a local web server at hand, you can start one together with the test suite:
pk-test --url=%ABSOLUTE_PAGE_URL% --serveDir=%PATH_TO_TEST_FOLDER%
You can set a custom port using the optional --port
argument.
Configuring a delay
In case you are unable to take a screenshot of some element because it hasn't loaded yet, you can configure a fixed delay before taking screenshots:
pk-test --url=%ABSOLUTE_PAGE_URL% --wait=3000
Tolerance
The tolerance level can be adjusting using the --tolerance
argument:
pk-test --url=%ABSOLUTE_PAGE_URL% --tolerance=1.25