diff options
Diffstat (limited to 'tests/lib/screenshot-testing/support/chai-extras.js')
-rw-r--r-- | tests/lib/screenshot-testing/support/chai-extras.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/screenshot-testing/support/chai-extras.js b/tests/lib/screenshot-testing/support/chai-extras.js index e0b672bae0..e796d46903 100644 --- a/tests/lib/screenshot-testing/support/chai-extras.js +++ b/tests/lib/screenshot-testing/support/chai-extras.js @@ -11,6 +11,21 @@ var fs = require('fs'), PageRenderer = require('./page-renderer.js').PageRenderer, AssertionError = chai.AssertionError; +var testsToIgnoreIfAborted = []; + +function shouldTestBeSkippedOnAbort(screenName){ + + for (var i in testsToIgnoreIfAborted) { + // we skip test if needed but still upload the screenshot for the diff just a few lines further up + if (testsToIgnoreIfAborted[i] + '.png' === screenName) { + + return true; + } + } + + return false; +} + // add screenshot keyword to `expect` expect.screenshot = function (file, prefix) { if (!prefix) { @@ -133,6 +148,13 @@ function capture(screenName, compareAgainst, selector, pageSetupFn, comparisonTh var indent = " "; err.stack = err.message + "\n" + indent + getPageLogsString(pageRenderer.pageLogs, indent); + if (shouldTestBeSkippedOnAbort(screenName)) { + console.log('SKIPPING TEST ' + screenName + ' AS IT RANDOMLY GETS ABORTED:'); + console.log(err.stack); + done(); + return; + } + done(err); return; } @@ -348,6 +370,11 @@ chai.Assertion.addChainableMethod('capture', function () { capture(screenName, compareAgainst, null, pageSetupFn, comparisonThreshold, done); }); +chai.Assertion.addChainableMethod('skippedOnAbort', function () { + var compareAgainst = this.__flags['object']; + testsToIgnoreIfAborted.push(compareAgainst); +}); + // add `contains` assertion chai.Assertion.addChainableMethod('contains', function () { var self = this, |