1111 *
1212 * @param options {Object} reporter options
1313 * id: {String} report id
14+ * env: {String} environment description
1415 */
1516function EarlReport ( options ) {
1617 let today = new Date ( ) ;
@@ -22,6 +23,7 @@ function EarlReport(options) {
2223 this . now = new Date ( ) ;
2324 this . now . setMilliseconds ( 0 ) ;
2425 this . id = options . id ;
26+ this . env = options . env ;
2527 /* eslint-disable quote-props */
2628 this . _report = {
2729 '@context' : {
@@ -30,6 +32,7 @@ function EarlReport(options) {
3032 'dc' : 'http://purl.org/dc/terms/' ,
3133 'earl' : 'http://www.w3.org/ns/earl#' ,
3234 'xsd' : 'http://www.w3.org/2001/XMLSchema#' ,
35+ 'jsonld' : 'http://www.w3.org/ns/json-ld#' ,
3336 'doap:homepage' : { '@type' : '@id' } ,
3437 'doap:license' : { '@type' : '@id' } ,
3538 'dc:creator' : { '@type' : '@id' } ,
@@ -73,17 +76,16 @@ function EarlReport(options) {
7376 'subjectOf' : [ ]
7477 } ;
7578 /* eslint-enable quote-props */
76- const version = require ( '../package.json' ) . version ;
77- // FIXME: Improve "Node.js" vs "browser" id reporting
78- // this._report['@id'] += '#' + this.id;
79- // this._report['doap:name'] += ' ' + this.id;
80- // this._report['dc:title'] += ' ' + this.id;
81- this . _report [ 'doap:release' ] [ 'doap:name' ] =
82- this . _report [ 'doap:name' ] + ' ' + version ;
83- this . _report [ 'doap:release' ] [ 'doap:revision' ] = version ;
79+ this . _report [ '@id' ] +=
80+ '#' + this . id ;
81+ this . _report [ 'doap:name' ] +=
82+ ' ' + this . id + ( this . env ? ' ' + this . env : '' ) ;
83+ this . _report [ 'dc:title' ] +=
84+ ' ' + this . id + ( this . env ? ' ' + this . env : '' ) ;
8485}
8586
86- EarlReport . prototype . addAssertion = function ( test , pass ) {
87+ EarlReport . prototype . addAssertion = function ( test , pass , options ) {
88+ options = options || { } ;
8789 this . _report . subjectOf . push ( {
8890 '@type' : 'earl:Assertion' ,
8991 'earl:assertedBy' : this . _report [ 'doap:developer' ] [ '@id' ] ,
@@ -93,6 +95,7 @@ EarlReport.prototype.addAssertion = function(test, pass) {
9395 '@type' : 'earl:TestResult' ,
9496 'dc:date' : this . now . toISOString ( ) ,
9597 'earl:outcome' : pass ? 'earl:passed' : 'earl:failed'
98+ . . . options . extra
9699 }
97100 } ) ;
98101 return this ;
0 commit comments