grafana/packages/grafana-e2e/cypress/plugins/compareSnapshots.js
Steven Vachon 23d72d25e4
@grafana/e2e: fix runtime ts-loader errors with Cypress support files (#22688)
* Minor changes

* Only exclude installed packages that are not @grafana/e2e itself

* Explicitly load Cypress tsconfig for clarity

* Fix Cypress tsconfig

  * it was trying to extend a config that is not published
  * it needs to be commonjs
2020-03-10 12:20:44 -04:00

26 lines
620 B
JavaScript

const BlinkDiff = require('blink-diff');
function compareSnapshotsPlugin(args) {
args.threshold = args.threshold || 0.001;
return new Promise((resolve, reject) => {
const diff = new BlinkDiff({
imageAPath: args.pathToFileA,
imageBPath: args.pathToFileB,
thresholdType: BlinkDiff.THRESHOLD_PERCENT,
threshold: args.threshold,
imageOutputPath: args.pathToFileA.replace('.png', '.diff.png'),
});
diff.run((error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
}
module.exports = compareSnapshotsPlugin;