Example #1
0
				this._it('should be similar', function (done) {

					var options = this._comparison,
						blinkDiff;

					options = utils.deepExtend({}, [options, this.screenConfig || {}]);

                    if (!this.approvedScreen) {
                        throw new Error('Approved screen is not loaded.');
                    }
                    if (!this.buildScreen) {
                        throw new Error('Build screen is not loaded.');
                    }

					options.imageA = this.approvedScreen;
					options.imageB = this.buildScreen;

					blinkDiff = new BlinkDiff(options);
					blinkDiff.run(function (err, result) {
						if (err) {
							done(err);
						} else {

							try {
								this._processTestResults(comparisonName, blinkDiff, result.code).then(function () {
									done();
								}, function (err) {
									done(err);
								});
							} catch (err) {
								done(err);
							}
						}
					}.bind(this));
				}.bind(this));
Example #2
0
function isSimilar(a, b, done) {
  var diff = new BlinkDiff({
    imageAPath: a,
    imageBPath: b,
    thresholdType: BlinkDiff.THRESHOLD_PERCENT,
    threshold: .01
  })
  diff.run((err, result) => {
    if (err) {
      return done(err)
    }

    done(null, diff.hasPassed(result.code))
  })
}
Example #3
0
  return new Promise((resolve, reject) => {
    var diff = new BlinkDiff({
      imageAPath: imageAPath, // Path
      imageB: imageB,         // Buffer
      thresholdType: BlinkDiff.THRESHOLD_PIXEL,
      threshold: threshold,
      imageOutputPath: outputPath,
      cropImageA:isIOS?{y:128}:{y:242,height:1530},//android: 242 - status bar(72)+navigator bar(170)
      cropImageB:isIOS?{y:128}:{y:242,height:1530}
    });

    diff.run((err, result) => {
      if (err) {
        return reject(err);
      }
      var ifPassed = diff.hasPassed(result.code);
      console.log(ifPassed ? 'Image Comparison Passed' : 'Image Comparison Failed');
      console.log(`Found ${result.differences} pixel differences between two images.`);
      resolve(ifPassed);
    });
  });