UNPKG

pix-diff

Version:

Protractor plugin for image comparison

19 lines (17 loc) 614 B
'use strict'; const PixelDiff = require('pixel-diff'); beforeEach(() => { jasmine.addMatchers({ toPass: () => { return { compare: actual => { var percent = +((actual.differences / actual.dimension) * 100).toFixed(2); return { pass: (actual.code === PixelDiff.RESULT_IDENTICAL) || (actual.code === PixelDiff.RESULT_SIMILAR), message: `Image is visibly different by ${actual.differences} pixels, ${percent}%` }; } }; } }); });