From cb0810d18ab3e24d334fc4675a469d6ce4011db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 22 May 2016 15:59:05 +0200 Subject: [PATCH] QUnit: Fix tests on Node v6. --- test/helpers.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/helpers.js b/test/helpers.js index fb58c2f4..4a6f7513 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -12,14 +12,14 @@ var isNode = typeof global === 'object', isPhantom = typeof window === 'object' && !!window.callPhantom, - root; + scope; if (isNode) { - root = global; + scope = global; // Resemble.js needs the Image constructor global. global.Image = paper.window.Image; } else { - root = window; + scope = window; // This is only required when running in the browser: // Until window.history.pushState() works when running locally, we need to // trick qunit into thinking that the feature is not present. This appears @@ -35,13 +35,16 @@ if (isNode) { } // The unit-tests expect the paper classes to be global. -paper.install(root); +paper.install(scope); // Override console.error, so that we can catch errors that are only logged to // the console. var errorHandler = console.error; console.error = function() { - QUnit.pushFailure([].join.call(arguments, ' '), QUnit.config.current.stack); + var current = QUnit.config.current; + if (current) { + QUnit.pushFailure([].join.call(arguments, ' '), current.stack); + } errorHandler.apply(this, arguments); };