diff --git a/bin/dredd b/bin/dredd index 98a62889d..fb0b7965f 100755 --- a/bin/dredd +++ b/bin/dredd @@ -1,10 +1,5 @@ #!/usr/bin/env node -/* eslint-disable global-require */ - -const fs = require('fs'); -const path = require('path'); - // Ignore this block, it's pure magic, temporary fix // for https://github.com/nodejs/node/issues/6456 [process.stdout, process.stderr].forEach((s) => { @@ -22,35 +17,4 @@ const dreddCli = new CLI({ }, }); -if (process.env.COVERAGE_DIR) { - process.on('exit', () => { - // Before Dredd exits, we need to collect coverage stats and save them to - // a file. We abuse 'mocha-lcov-reporter' to do this. - const LCov = require('mocha-lcov-reporter'); - - // Pretending there is Mocha runner - const EventEmitter = require('events').EventEmitter; - const runner = new EventEmitter(); - - // Monkey-patching 'LCov.prototype.write' to catch all output to a variable - let content = ''; - const write = LCov.prototype.write; - - LCov.prototype.write = (string) => { - content += string; - }; - - // Collecting the stats - new LCov(runner); - runner.emit('end'); - - // Undo the monkey-patching - LCov.prototype.write = write; - - // Save stats as lcov file - const file = path.join(process.env.COVERAGE_DIR, 'dredd-bin.info'); - fs.appendFileSync(file, content); - }); -} - dreddCli.run(); diff --git a/package.json b/package.json index 01fbf637b..ca72702a9 100644 --- a/package.json +++ b/package.json @@ -71,9 +71,7 @@ "eslint-config-airbnb-base": "13.2.0", "eslint-plugin-import": "2.18.2", "express": "4.17.1", - "lcov-result-merger": "3.1.0", "mocha": "6.2.0", - "mocha-lcov-reporter": "1.3.0", "nock": "10.0.6", "ps-node": "0.1.6", "semantic-release": "15.13.17", diff --git a/test/mocha.opts b/test/mocha.opts index b7eb5466f..eb637f4c3 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,3 +1,2 @@ ---reporter=test/reporter.js --timeout=120000 --recursive diff --git a/test/reporter.js b/test/reporter.js deleted file mode 100644 index 698726736..000000000 --- a/test/reporter.js +++ /dev/null @@ -1,29 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const Spec = require('mocha').reporters.Spec; -const LCov = require('mocha-lcov-reporter'); - -/** - * Combined reporter - * - * Behaves the same way as Mocha's built-in 'Spec' reporter, but if - * the environment variable 'COVERAGE_DIR' is set to a directory, - * collects code coverage to './lcov/mocha.info' file. - * - * If you want to learn more about how coverage collecting works - * in Dredd's test suite, see the 'npm run test:coverage' script. - */ -module.exports = function reporter(runner, options) { - new Spec(runner, options); - - if (process.env.COVERAGE_DIR) { - // Monkey-patching the 'LCov.prototype.write' so we could save - // the LCov output to a file instead of a standard output - LCov.prototype.write = function write(string) { - const file = path.join(process.env.COVERAGE_DIR, 'mocha.info'); - fs.appendFileSync(file, string); - }; - new LCov(runner, options); - } -};