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