BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

misMatchThreshold Value

Open ghost opened this issue 10 years ago • 24 comments

The usage information doesn't provide a context for this value. Is it a percentage?

ghost avatar Oct 10 '16 15:10 ghost

@grayloon Hi, thanks for posting. I have gotten a lot of requests for this -- it's a good question.

The raw value comes from here:

https://github.com/Huddle/Resemble.js/blob/af57cb2f4edfbe718d24b350b2be1d956b764298/resemble.js#L495

(mismatchCount / (height*width) * 100)

Hope that helps!

garris avatar Oct 10 '16 22:10 garris

Hi @garris

In my config file I have misMatchThreshold = 15.00

A URL that failed shows this in the log: compare | ERROR { size: isDifferent, content: 3.97%, threshold: 15% }

The HTML report shows this for that page: misMatchPercentage": "3.97"

The way I interpret this is that the page had a 3.97% difference. But shouldn't the difference be 15%+ before it fails?

robertloo avatar Mar 29 '17 21:03 robertloo

@robertloo hi, thanks for posting. It looks like you have a size = "isDifferent" in your result.

This will cause a fail regardless of your threshold.

Please check the browser report -- you will probably see a very distorted diff image. the test may be revealing an unintended size change?

garris avatar Mar 30 '17 01:03 garris

@garris the DIFF image shows the footer slighting distorted. Everything else looks fine.

In my config file I set requireSameDimensions = false. Should that not have made it to ignore the dimension difference?

Here is another failed test with the HTML error report:

Report: {
  "isSameDimensions": false,
  "dimensionDifference": {
    "width": 0,
    "height": -33
  },
  "misMatchPercentage": "6.58",
  "getDiffImage": null
}
Threshold: 1

I still have my misMatchThreshold at 15.00 in the config file. Here it says it is 1. Maybe my threshold value is not being passed?

robertloo avatar Mar 30 '17 02:03 robertloo

Yes, you're doing everything right. That feature, requireSameDimentions was just added and in fact, is not yet in @latest.

Try installing canary... npm install -g backstopjs@canary

Sorry in advance if canary has any issues. I didn't have a chance to check on the last push.

That feature was added for exactly this situation. Please let me know if it addresses your issue.

Thanks!

garris avatar Mar 30 '17 02:03 garris

I installed canary. I think this is working better. I constantly get good test runs (12 pages/test). But every so often I get one with a failing page, like this:

Report: {
  "isSameDimensions": false,
  "dimensionDifference": {
    "width": 0,
    "height": -6
  },
  "misMatchPercentage": "1.83",
  "getDiffImage": null
}
Threshold: 1

Log compare | ERROR { requireSameDimensions: false size: isDifferent, content: 1.83%, threshold: 15% }

robertloo avatar Mar 30 '17 04:03 robertloo

Are you saying you get different results when running backstop test multiple times without making changes?

garris avatar Mar 30 '17 05:03 garris

Correct. I'm using a decent connection. Here are more of my settings:

var selectors = ["document"];
var delay = 3000;
var misMatchThreshold = 15.00;
var requireSameDimensions = false;
    viewports: [
      {
        name: "desktop",
        width: 1500,
        height: 1200
      }
    ],
    engine: "phantomjs",

My guess is phantomjs does not handle large displays well consistently. I was hoping to mitigate that inconstancy with a high misMatchThreshold. I could raise it higher. But fear that might start giving me false negatives.

robertloo avatar Mar 30 '17 13:03 robertloo

It'd be useful to get an output log for a successful test and then one for a failing test. Also, a couple of screenshots from each test. @robertloo

jtuds avatar Mar 30 '17 14:03 jtuds

Try testing smaller regions using selectors. Also, check for Ajax content and or animations that are still running during your test. That is usually the issue.

garris avatar Mar 30 '17 15:03 garris

@jtuds the console log of a successful test of that failing test mentioned above shows this: compare | OK: <url...>

@garris I think Ajax might be the cause. Putting that aside though, I would expect the misMatchPercentage to be over 15% on a failing test. I don't mind getting fail tests like this every so often. I'm going to try 20% threshold and see if that helps.

Thanks for the awesome project! :)

robertloo avatar Mar 30 '17 16:03 robertloo

@robertloo I am concerned because it sounds like "isSameDimensions": false is still triggering a false negative? I am not clear if this is true or if installing @canary fixed this issue? Could you let me know? Thanks!

garris avatar Mar 30 '17 16:03 garris

If possible. I would try run some tests on an isolated, very small and single scenario. Then repeat it a few times and see if you get any false negatives. If you are getting false negatives on a very small, simple HTML page with no Javascript or styling then this could be an issue with the functionality rather than your use case. @robertloo

jtuds avatar Mar 30 '17 17:03 jtuds

I created two empty tables

Table A (reference) height: 50%; width: 50%;

Table B (test) height: 80%; width: 80%;

Config settings var misMatchThreshold = 15.00; var requireSameDimensions = false;

Log report compare | ERROR { requireSameDimensions: false size: isDifferent, content: 22.44%, threshold: 15% }:

HTML report table-test

Table B (TEST) is proportionally bigger even though you can't see it here. So the dimension is different. But it is the same thing.

robertloo avatar Mar 31 '17 05:03 robertloo

Your mismatch is over the threshold in this instance though, requireSameDimensions won't stop a test that is over the mismatch threshold from failing. What happens if you make it under the mismatch, say 14%, and then run the tests?

jtuds avatar Mar 31 '17 07:03 jtuds

@jtuds Good point!

Here is another test. Same settings as before, except var misMatchThreshold = 23.00;

Log report compare | ERROR { requireSameDimensions: false size: isDifferent, content: 22.44%, threshold: 23% }:

HTML report test-backstopjs

robertloo avatar Mar 31 '17 12:03 robertloo

Hm, this looks like it may be a bug. I see you are setting your options with variables, e.g. var misMatchThreshold = 23. How are you passing these to the Backstop config file/s?

jtuds avatar Mar 31 '17 13:03 jtuds

I'm running my config as a node module using --configPath

robertloo avatar Mar 31 '17 13:03 robertloo

Ok, this sounds like it is a bug and needs looking at. @garris If you agree, can you reopen this issue?

jtuds avatar Mar 31 '17 15:03 jtuds

Thank you for working on this!

garris avatar Apr 02 '17 15:04 garris