diff --git a/src/transaction-runner.coffee b/src/transaction-runner.coffee index cdd2b3d2e..b63580c35 100644 --- a/src/transaction-runner.coffee +++ b/src/transaction-runner.coffee @@ -197,6 +197,15 @@ class TransactionRunner sandboxedWrappedCode: (hookCode) -> return """ + // make console unavailable + try { + // node >= 8 + console = undefined; + } catch (_exc) { + // node < 8 + var console = undefined; + } + // run the hook var log = _log.bind(null, _logs); diff --git a/test/unit/transaction-runner-test.coffee b/test/unit/transaction-runner-test.coffee index 0133474da..8dcdd41bd 100644 --- a/test/unit/transaction-runner-test.coffee +++ b/test/unit/transaction-runner-test.coffee @@ -2468,5 +2468,5 @@ describe 'TransactionRunner', -> """ runner.runHook hook, {}, (err) -> assert.isDefined err - assert.include err, 'console' + assert.include err, 'Cannot read property \'log\' of undefined' done()