From 129ed0a6c50673ffc9f33b81ca620898af5a5b11 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 13 Apr 2015 08:40:40 -0600 Subject: [PATCH 1/2] Append directly to the document body --- test/test-extensions.js | 4 ++-- test_rendering/index.html | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test-extensions.js b/test/test-extensions.js index c9cdac18a5..0edf6c5e66 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -359,7 +359,7 @@ function resembleCanvas(canvas, referenceImage, tolerance, done) { if (window.showMap) { - document.getElementById('debug').appendChild(canvas); + document.body.appendChild(canvas); } resemble(referenceImage) @@ -376,7 +376,7 @@ if (window.showDiff) { var diffImage = new Image(); diffImage.src = data.getImageDataUrl(); - document.getElementById('debug').appendChild(diffImage); + document.body.appendChild(diffImage); } expect(data.misMatchPercentage).to.be.below(tolerance); } diff --git a/test_rendering/index.html b/test_rendering/index.html index b0293d06d0..b4543f0a50 100644 --- a/test_rendering/index.html +++ b/test_rendering/index.html @@ -88,6 +88,5 @@ Tests should not depend on any specific markup and should instead create whatever elements are needed (cleaning up when done). --> -
From 401ab6e829d51370d1bae6936bbd85414b342fc9 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 13 Apr 2015 08:45:27 -0600 Subject: [PATCH 2/2] Keep custom test logic in one place --- test/test-extensions.js | 10 ++++++++-- test_rendering/index.html | 12 ------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/test/test-extensions.js b/test/test-extensions.js index 0edf6c5e66..e4605ffc24 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -3,6 +3,12 @@ // helper functions for async testing and other utility functions. (function(global) { + // show generated maps for rendering tests + var showMap = (global.location.search.indexOf('generate') >= 0); + + // show a diff when rendering tests fail + var showDiff = (global.location.search.indexOf('showdiff') >= 0); + /** * The default tolerance for image comparisons. */ @@ -358,7 +364,7 @@ }; function resembleCanvas(canvas, referenceImage, tolerance, done) { - if (window.showMap) { + if (showMap) { document.body.appendChild(canvas); } @@ -373,7 +379,7 @@ } if (data.misMatchPercentage > tolerance) { - if (window.showDiff) { + if (showDiff) { var diffImage = new Image(); diffImage.src = data.getImageDataUrl(); document.body.appendChild(diffImage); diff --git a/test_rendering/index.html b/test_rendering/index.html index b4543f0a50..400ca8c3ec 100644 --- a/test_rendering/index.html +++ b/test_rendering/index.html @@ -51,18 +51,6 @@ } }); - window.showDiff = false; - if (window.location.search.indexOf('showdiff') >= 0) { - // show a difference image if '?showdiff' is in the URL - window.showDiff = true; - } - - window.showMap = false; - if (window.location.search.indexOf('generate') >= 0) { - // show the canvas of the test map if '?generate' is in the URL - window.showMap = true; - } - if (window.console && console.log) { // write stacks to the console for failed tests runner.on('fail', function(test, err) {