Skip to main content

Comparing Screenshots in JavaScript with Applitools

Prerequisites

  1. A free Applitools account and Applitools API KEY
Tip: Unsure how to find your API key?

Read Retrieving your API key to find your API key.

  1. Node.js

  2. Git

Note: Installing git is optional

Installing git is used to clone the demo project from the Github repository. Instead of installing git, you can simply download the Zip file from the repository. Further, if you are Mac, you already have git.

Running the Example Project

  1. Clone or download the repository and navigate to that folder
git clone https://github.com/applitools/tutorial-images-javascript.git
cd tutorial-images-javascript

Note: you can alternatively download the project as a Zip file and extract it

  1. Install the dependencies
npm install
  1. Run the example test

To run all of the tests, run:

APPLITOOLS_API_KEY="[Your API Key]" npm test

Adding Applitools Eyes to an Existing Node.js Project

Install Applitools Eyes dependencies:

npm install @applitools/eyes-images --save-dev

Sample test


Download the following image and place it next your test file:

Note: Image Location

The test example currently expects the image to be placed next to it. If you prefer it to be in another location, be sure to update the location in the test.

Applitools Eyes JavaScript Images SDK

How it works

The Applitools Eyes Screenshot JavaScript SDK allows you to easily add visual checkpoints to your JavaScript images tests. It takes care of images given by the user, sending them to the Eyes server for validation and failing the test in case differences are found.

More information

The @applitools/eyes-images npm package page contain more information. Visit eyes-images SDK repo to find out more about what's possible with Applitools' JavaScript Images SDK.

Having Trouble?

Don't suffer in silence! Let us help you. Please reach out to us to get your project working.

Taking the next steps with Applitools

Congratulations on completing this quickstart! There's still so much to learn about visual testing with Applitools, but you're off to a great start.

Resources for next steps:

  1. ↔️ Setting match levels for visual checkpoints
  2. Organizing Tests Into Batches

You can also: