add html report for integrity tests

This commit is contained in:
Michele Guerini Rocco 2018-06-21 03:30:24 +02:00
parent 68f56ede58
commit f000022189
Signed by: rnhmjoj
GPG Key ID: 91BE884FBA4B591A
4 changed files with 15 additions and 11 deletions

View File

@ -11,6 +11,7 @@
"coffeescript": "^1.9.2", "coffeescript": "^1.9.2",
"fast-levenshtein": "^2.0.6", "fast-levenshtein": "^2.0.6",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"mochawesome": "^3.0.1",
"mock-fs": "^4.5.0", "mock-fs": "^4.5.0",
"nyc": "^13.0.0", "nyc": "^13.0.0",
"moment": "^2.22.2", "moment": "^2.22.2",
@ -35,7 +36,7 @@
"hubot-youtube": "^1.1.0" "hubot-youtube": "^1.1.0"
}, },
"scripts": { "scripts": {
"test": "nyc mocha test/*.coffee; true" "test": "nyc mocha; true"
}, },
"nyc": { "nyc": {
"include": [ "include": [
@ -49,6 +50,7 @@
"json-summary", "json-summary",
"html" "html"
], ],
"report-dir": "report/coverage",
"sourceMap": true, "sourceMap": true,
"instrument": true, "instrument": true,
"cache": true "cache": true

View File

@ -19,8 +19,8 @@ fs = require 'fs'
module.exports = (robot) -> module.exports = (robot) ->
robot.respond /(?:mostrami la )?(?:copertura|coverage)(?: dei test)?/i, (res) -> robot.respond /(?:mostrami la )?(?:copertura|coverage)(?: dei test)?/i, (res) ->
url = 'https://maxwell.ydns.eu/asjon/coverage' url = 'https://maxwell.ydns.eu/asjon/report/coverage'
file = 'coverage/coverage-summary.json' file = 'report/coverage/coverage-summary.json'
try try
report = JSON.parse (fs.readFileSync file, 'utf8') report = JSON.parse (fs.readFileSync file, 'utf8')
@ -41,5 +41,5 @@ module.exports = (robot) ->
#{files.join '\n'} #{files.join '\n'}
HTML report: #{url} HTML report: #{url}
JSON report: #{url}/coverage-final.json JSON report: #{url}/coverage-summary.json
""" """

View File

@ -10,7 +10,9 @@ describe 'modulo coverage', ->
Asjon (assa) -> Asjon (assa) ->
asjon = assa asjon = assa
after asjon.after after asjon.after
afterEach asjon.clear afterEach () ->
asjon.clear()
mock.restore()
require('../scripts/coverage.coffee')(asjon.robot) require('../scripts/coverage.coffee')(asjon.robot)
done() done()
@ -31,8 +33,7 @@ describe 'modulo coverage', ->
it 'dovrebbe reagire correttamente ad un errore di parsing', (done) -> it 'dovrebbe reagire correttamente ad un errore di parsing', (done) ->
# broken report # broken report
mock mock
'coverage/coverage-summary.json': '{' 'report/coverage/coverage-summary.json': '{'
asjon.receive (e,l) -> asjon.receive (e,l) ->
l.join().should.match /^errore nel leggere il report:\nSyntaxError/g l.join().should.match /^errore nel leggere il report:\nSyntaxError/g
done() done()
@ -41,7 +42,7 @@ describe 'modulo coverage', ->
it 'dovrebbe reagire correttamente quando il report non è disponibile', (done) -> it 'dovrebbe reagire correttamente quando il report non è disponibile', (done) ->
# missing report # missing report
mock mock
'coverage/coverage-summary.json': 'report/coverage/coverage-summary.json':
mock.symlink path: '/no-such-file' mock.symlink path: '/no-such-file'
asjon.receive (e,l) -> asjon.receive (e,l) ->
l.join().should.match /^report non disponibile/g l.join().should.match /^report non disponibile/g
@ -51,13 +52,11 @@ describe 'modulo coverage', ->
it 'dovrebbe parsare correttamente il report json', (done) -> it 'dovrebbe parsare correttamente il report json', (done) ->
# fake report # fake report
mock mock
'coverage/coverage-summary.json': JSON.stringify 'report/coverage/coverage-summary.json': JSON.stringify
total: lines: pct: 73.11 total: lines: pct: 73.11
'a/b.coffee': lines: pct: 92.12 'a/b.coffee': lines: pct: 92.12
'a/c.coffee': lines: pct: 81.67 'a/c.coffee': lines: pct: 81.67
asjon.receive (e,l) -> asjon.receive (e,l) ->
l.join().should.match /^=== Coverage: /g l.join().should.match /^=== Coverage: /g
mock.restore()
done() done()
asjon.send 'asjon coverage' asjon.send 'asjon coverage'

3
test/mocha.opts Normal file
View File

@ -0,0 +1,3 @@
test/*.coffee
--reporter mochawesome
--reporter-options reportDir=report,reportFilename=index,json=false,quiet=true