Image assertion with node js

Recently I started with automation testing. I got a scenario where we need to assert the images. That became very tough situation for us and we just ignored that for now. Then I started few research like whether we can assert images with Node js. Yes!! we can do it with the help of looks-same

To get it started, you need to first install node js in your machine. You may need the npm package — looks-same.

Get the Visual studio code and open a new terminal inside and type below to initiate node package manager,

Now, lets install the image assertion npm package called looks-same by typing following in terminal,

That’s it! Now you can make use of this package inside your code.

Syntax:

Get the two images, which you want to compare and paste their location inside the function. You can use console.log() to print the assertion result using the variable ‘equal’ and save it as .js file,

Now, you can run the javascript file with below command,

Yeah!!! you did it. Based upon your input, it may return true or false.

--

--

Programmer who loves to do things creatively. #automationTester by profession #javascript #nodejs #reactjs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Siddharth Murugan

Programmer who loves to do things creatively. #automationTester by profession #javascript #nodejs #reactjs