See this Medium article for more information
-
The set up is a simple web app using
create-react-app
and nothing much else. -
TestCafe and Resemblejs have been imported as devDependencies (along with
path
andfs-extra
) -
There is a TestCafe test script in our
package.json
to run TestCafenpm run test
=>testcafe firefox:headless -s ./tests/vrt-screenshots ./tests/*visual.test.js
npm run test
is called (requires the server to be already started usingnpm start
)tests/App.visual.test.js
navigates to the homepage and callstests/vrt-util/vrtUtil.js
exported functiondoVisualRegression(testFixture, testName)
doVisualRegression(..)
takes the screenshots and stores them in anactual
andbase
folder (if no base screenshot exists.- If an
actual
andbase
screenshot exists, perform the comparison using Resemblejs. If the comparison detects a mismatch, fail the test and output a diff image in theactual
folder.