From 15ee659c9c259df48290ba193d61e3ee7d57f2c9 Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Fri, 26 Feb 2021 12:46:41 +0100 Subject: [PATCH] Exit with error on unhandled rejections in Node tests (#1251) --- test/general/key.js | 14 +++++++------- test/unittests.js | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/general/key.js b/test/general/key.js index d0e4d69d..d52a8d56 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -3108,17 +3108,17 @@ module.exports = () => describe('Key', function() { const source = await openpgp.readKey({ armoredKey: priv_key_rsa }); const [dest] = await openpgp.readKeys({ armoredKeys: twoKeys }); expect(dest.isPublic()).to.be.true; - return dest.update(source).then(() => { + return dest.update(source).then(async () => { expect(dest.isPrivate()).to.be.true; return Promise.all([ - dest.verifyPrimaryKey().then(result => { - expect(source.verifyPrimaryKey()).to.eventually.equal(result); + dest.verifyPrimaryKey().then(async result => { + await expect(source.verifyPrimaryKey()).to.eventually.equal(result); }), - dest.users[0].verify(dest.primaryKey).then(result => { - expect(source.users[0].verify(source.primaryKey)).to.eventually.equal(result); + dest.users[0].verify(dest.primaryKey).then(async result => { + await expect(source.users[0].verify(source.primaryKey)).to.eventually.equal(result); }), - dest.subKeys[0].verify(dest.primaryKey).then(result => { - expect(source.subKeys[0].verify(source.primaryKey)).to.eventually.equal(result); + dest.subKeys[0].verify(dest.primaryKey).then(async result => { + await expect(source.subKeys[0].verify(source.primaryKey)).to.eventually.deep.equal(result); }) ]); }); diff --git a/test/unittests.js b/test/unittests.js index f7156814..75661268 100644 --- a/test/unittests.js +++ b/test/unittests.js @@ -40,6 +40,11 @@ describe('Unit Tests', function () { } catch (e) {} } }); + } else { + process.on('unhandledRejection', error => { + console.error(error); // eslint-disable-line no-console + process.exit(1); // eslint-disable-line no-process-exit + }); } require('./crypto')();