✅What is visual E2E testing?
✅How to implement visual e2e testing for a web app
✅ Easier than e2e tests
✅ Validate an entire page in a single LOC
✅ Check how an app looks in different Browsers/Resolutions
✅ More stable than e2e tests
✅ Can help reduce the size of e2e suite
Next-gen browser and mobile automation test framework for Node.js
Automatically detect visual regressions across your UI
follow along
- Go to file
/test/specs/visual.exercise.spec.js
- Paste the following code
describe('My app', () => {
it('should look correct', async () => {
await browser.url('');
await browser.execute('/*@visual.init*/', 'My React App');
await browser.execute('/*@visual.snapshot*/', 'Home Page');
const result = await browser.execute('/*@visual.end*/');
expect(result.message).toBeNull();
});
});
- In your terminal
npm run test:visual
- View the execution in Saucelabs.com
Let's fill out the Test coverage
We're going to update the React image to something better. What tests should break?
- Drag'n drop a new image to the
/src
folder - In
App.js
, Fix the path of the image to match your new image nameimport logo from './mia.jpg';
- Save all files
- Stop the React app
ctrl + C
in the server terminal - Restart the app with
npm start
- Rerun the visual tests with
npm run test:visual
- Notice the results in your terminal
- Do it
- Rerun visual tests
npm run test:visual
✅Visual e2e testing is a simple and efficient way to ensure visual consistency cross-platform and cross-OS
✅We used WebdriverIO + Screener.io to write our visual e2e tests