From 89333185a92209ab1f9d6b937040e8b687b45559 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 28 Dec 2017 16:37:17 +0000 Subject: [PATCH 1/2] Make tests to fail if they got an uncaught exception --- test/support/test_helper.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/support/test_helper.js b/test/support/test_helper.js index 49c6c1ee..96a109ff 100644 --- a/test/support/test_helper.js +++ b/test/support/test_helper.js @@ -75,6 +75,22 @@ function checkSurrogateKey(res, expectedKey) { assert.deepEqual(keys, expectedKeys); } +var uncaughtExceptions = []; +process.on('uncaughtException', function(err) { + uncaughtExceptions.push(err); +}); +beforeEach(function() { + uncaughtExceptions = []; +}); +//global afterEach to capture uncaught exceptions +afterEach(function() { + assert.equal( + uncaughtExceptions.length, + 0, + 'uncaughtException:\n\n' + uncaughtExceptions.map(err => err.stack).join('\n\n')); +}); + + var redisClient; beforeEach(function() { From d7f4d39aa2631e407585dd6f5b48138d8343026e Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 28 Dec 2017 18:09:41 +0000 Subject: [PATCH 2/2] Don't not override the full client but only the provided methods --- test/unit/cartodb/ported/tile_stats.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/cartodb/ported/tile_stats.test.js b/test/unit/cartodb/ported/tile_stats.test.js index 3fbf93ec..a2d30cd0 100644 --- a/test/unit/cartodb/ported/tile_stats.test.js +++ b/test/unit/cartodb/ported/tile_stats.test.js @@ -11,7 +11,7 @@ describe('tile stats', function() { }); afterEach(function() { - global.statsClient = this.statsClient; + global.statsClient = this.statsClient; }); it('finalizeGetTileOrGrid does not call statsClient when format is not supported', function() { @@ -84,7 +84,7 @@ describe('tile stats', function() { }); function mockStatsClientGetInstance(instance) { - global.statsClient = instance; + global.statsClient = Object.assign(global.statsClient, instance); } });