From d9af5ac57106aad4bca5cb04818941186bdf422e Mon Sep 17 00:00:00 2001 From: cgewecke Date: Fri, 29 Nov 2019 16:34:01 -0800 Subject: [PATCH] Gracefully overwrite eth-gas-reporter (#448) --- plugins/resources/truffle.utils.js | 6 ++++++ test/units/truffle/standard.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/resources/truffle.utils.js b/plugins/resources/truffle.utils.js index 3f430bd..80ac81a 100644 --- a/plugins/resources/truffle.utils.js +++ b/plugins/resources/truffle.utils.js @@ -194,6 +194,12 @@ function normalizeConfig(config){ config.testDir = config.test_directory; config.artifactsDir = config.build_directory; + // eth-gas-reporter freezes the in-process client because it uses sync calls + if (typeof config.mocha === "object" && config.mocha.reporter === 'eth-gas-reporter'){ + config.mocha.reporter = 'spec'; + delete config.mocha.reporterOptions; + } + return config; } diff --git a/test/units/truffle/standard.js b/test/units/truffle/standard.js index 1c281fe..dd54b3a 100644 --- a/test/units/truffle/standard.js +++ b/test/units/truffle/standard.js @@ -215,6 +215,14 @@ describe('Truffle Plugin: standard use cases', function() { ); }); + // This test errors if the reporter is not re-designated as 'spec' correctly + it('gracefully disables eth-gas-reporter', async function(){ + truffleConfig.mocha = { reporter: 'eth-gas-reporter' }; + + mock.install('Simple', 'simple.js', solcoverConfig); + await plugin(truffleConfig); + }); + // This test tightly coupled to the ganache version in production deps // "test-files" project solcoverjs includes `client: require('ganache-cli')` it('config: client', async function(){