From 7718240e0f5606024c2018a0a2bac89707c9b36e Mon Sep 17 00:00:00 2001 From: Nick Hehr Date: Sat, 16 Jan 2016 15:19:22 -0500 Subject: [PATCH] test(deploy): catch swallowed copySync errors --- test/unit/deploy.js | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/test/unit/deploy.js b/test/unit/deploy.js index 24d958c9..e65d4e02 100644 --- a/test/unit/deploy.js +++ b/test/unit/deploy.js @@ -1,3 +1,6 @@ +process.on('uncaughtException', function(err) { + console.error(err.stack); +}); // Test dependencies are required and exposed in common/bootstrap.js var meminfo = fs.readFileSync('test/unit/fixtures/proc-meminfo', 'utf8'); @@ -1642,9 +1645,41 @@ exports['deploy.injectBinaryModules'] = { ); test.done(); - }).catch(error => test.fail(error)); - }).catch(error => test.fail(error)); + }).catch(error => { + test.fail(error); + test.done(); + }); + }).catch(error => { + test.fail(error); + test.done(); + }); }, + + throwError: function(test) { + test.expect(1); + + var errorMessage = 'Test Error'; + this.copySync.onCall(0).throws(errorMessage); + + this.getRoot = sandbox.stub(bindings, 'getRoot', () => { + return path.normalize('node_modules/bufferutil/'); + }); + + deploy.resolveBinaryModules({ + target: this.target + }).then(() => { + deploy.injectBinaryModules(this.globRoot, fsTemp.mkdirSync()).then(() => { + test.fail('Should not pass'); + test.done(); + }).catch(error => { + test.equal(error, errorMessage); + test.done(); + }); + }).catch(error => { + test.fail(error); + test.done(); + }); + } };