diff --git a/package.json b/package.json index 97e45d1..264101f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "coffeescript": "^1.9.2", "fast-levenshtein": "^2.0.6", "mocha": "^5.2.0", + "mochawesome": "^3.0.1", "mock-fs": "^4.5.0", "nyc": "^13.0.0", "moment": "^2.22.2", @@ -35,7 +36,7 @@ "hubot-youtube": "^1.1.0" }, "scripts": { - "test": "nyc mocha test/*.coffee; true" + "test": "nyc mocha; true" }, "nyc": { "include": [ @@ -49,6 +50,7 @@ "json-summary", "html" ], + "report-dir": "report/coverage", "sourceMap": true, "instrument": true, "cache": true diff --git a/scripts/coverage.coffee b/scripts/coverage.coffee index 558f75c..03dec7a 100644 --- a/scripts/coverage.coffee +++ b/scripts/coverage.coffee @@ -19,8 +19,8 @@ fs = require 'fs' module.exports = (robot) -> robot.respond /(?:mostrami la )?(?:copertura|coverage)(?: dei test)?/i, (res) -> - url = 'https://maxwell.ydns.eu/asjon/coverage' - file = 'coverage/coverage-summary.json' + url = 'https://maxwell.ydns.eu/asjon/report/coverage' + file = 'report/coverage/coverage-summary.json' try report = JSON.parse (fs.readFileSync file, 'utf8') @@ -41,5 +41,5 @@ module.exports = (robot) -> #{files.join '\n'} HTML report: #{url} - JSON report: #{url}/coverage-final.json + JSON report: #{url}/coverage-summary.json """ diff --git a/test/coverage-test.coffee b/test/coverage-test.coffee index e0cdf6e..b706ffa 100644 --- a/test/coverage-test.coffee +++ b/test/coverage-test.coffee @@ -10,7 +10,9 @@ describe 'modulo coverage', -> Asjon (assa) -> asjon = assa after asjon.after - afterEach asjon.clear + afterEach () -> + asjon.clear() + mock.restore() require('../scripts/coverage.coffee')(asjon.robot) done() @@ -31,8 +33,7 @@ describe 'modulo coverage', -> it 'dovrebbe reagire correttamente ad un errore di parsing', (done) -> # broken report mock - 'coverage/coverage-summary.json': '{' - + 'report/coverage/coverage-summary.json': '{' asjon.receive (e,l) -> l.join().should.match /^errore nel leggere il report:\nSyntaxError/g done() @@ -41,7 +42,7 @@ describe 'modulo coverage', -> it 'dovrebbe reagire correttamente quando il report non รจ disponibile', (done) -> # missing report mock - 'coverage/coverage-summary.json': + 'report/coverage/coverage-summary.json': mock.symlink path: '/no-such-file' asjon.receive (e,l) -> l.join().should.match /^report non disponibile/g @@ -51,13 +52,11 @@ describe 'modulo coverage', -> it 'dovrebbe parsare correttamente il report json', (done) -> # fake report mock - 'coverage/coverage-summary.json': JSON.stringify + 'report/coverage/coverage-summary.json': JSON.stringify total: lines: pct: 73.11 'a/b.coffee': lines: pct: 92.12 'a/c.coffee': lines: pct: 81.67 - asjon.receive (e,l) -> l.join().should.match /^=== Coverage: /g - mock.restore() done() asjon.send 'asjon coverage' diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..30cd914 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,3 @@ +test/*.coffee +--reporter mochawesome +--reporter-options reportDir=report,reportFilename=index,json=false,quiet=true