@@ -33,31 +33,44 @@ module.exports = MochaJUnitReporter;
33
33
// regex lifted from https://github.com/MylesBorins/xml-sanitizer/ (licensed MIT)
34
34
var INVALID_CHARACTERS_REGEX = / [ \u0000 - \u0008 \u000B \u000C \u000E - \u001F \u007f - \u0084 \u0086 - \u009f \uD800 - \uDFFF \uFDD0 - \uFDFF \uFFFF \uC008 ] / g; //eslint-disable-line no-control-regex
35
35
36
+ function findReporterOptions ( options ) {
37
+ if ( ! options ) {
38
+ return { } ;
39
+ }
40
+ if ( ! mocha6plus ) {
41
+ return options . reporterOptions || { } ;
42
+ }
43
+ return Object . keys ( options ) . filter ( function ( key ) { return key . indexOf ( 'reporterOptions.' ) === 0 ; } )
44
+ . reduce ( function ( reporterOptions , key ) {
45
+ reporterOptions [ key . substring ( 'reporterOptions.' . length ) ] = options [ key ] ;
46
+ return reporterOptions ;
47
+ } , { } ) ;
48
+ }
49
+
36
50
function configureDefaults ( options ) {
37
- debug ( options ) ;
38
- options = options || { } ;
39
- options = options . reporterOptions || { } ;
40
- options . mochaFile = getSetting ( options . mochaFile , 'MOCHA_FILE' , 'test-results.xml' ) ;
41
- options . attachments = getSetting ( options . attachments , 'ATTACHMENTS' , false ) ;
42
- options . antMode = getSetting ( options . antMode , 'ANT_MODE' , false ) ;
43
- options . jenkinsMode = getSetting ( options . jenkinsMode , 'JENKINS_MODE' , false ) ;
44
- options . properties = getSetting ( options . properties , 'PROPERTIES' , null , parsePropertiesFromEnv ) ;
45
- options . toConsole = ! ! options . toConsole ;
46
- options . rootSuiteTitle = options . rootSuiteTitle || 'Root Suite' ;
47
- options . testsuitesTitle = options . testsuitesTitle || 'Mocha Tests' ;
48
-
49
- if ( options . antMode ) {
50
- updateOptionsForAntMode ( options ) ;
51
+ var config = findReporterOptions ( options ) ;
52
+ debug ( 'options' , config ) ;
53
+ config . mochaFile = getSetting ( config . mochaFile , 'MOCHA_FILE' , 'test-results.xml' ) ;
54
+ config . attachments = getSetting ( config . attachments , 'ATTACHMENTS' , false ) ;
55
+ config . antMode = getSetting ( config . antMode , 'ANT_MODE' , false ) ;
56
+ config . jenkinsMode = getSetting ( config . jenkinsMode , 'JENKINS_MODE' , false ) ;
57
+ config . properties = getSetting ( config . properties , 'PROPERTIES' , null , parsePropertiesFromEnv ) ;
58
+ config . toConsole = ! ! config . toConsole ;
59
+ config . rootSuiteTitle = config . rootSuiteTitle || 'Root Suite' ;
60
+ config . testsuitesTitle = config . testsuitesTitle || 'Mocha Tests' ;
61
+
62
+ if ( config . antMode ) {
63
+ updateOptionsForAntMode ( config ) ;
51
64
}
52
65
53
- if ( options . jenkinsMode ) {
54
- updateOptionsForJenkinsMode ( options ) ;
66
+ if ( config . jenkinsMode ) {
67
+ updateOptionsForJenkinsMode ( config ) ;
55
68
}
56
69
57
- options . suiteTitleSeparedBy = options . suiteTitleSeparedBy || ' ' ;
58
- options . suiteTitleSeparatedBy = options . suiteTitleSeparatedBy || options . suiteTitleSeparedBy ;
70
+ config . suiteTitleSeparedBy = config . suiteTitleSeparedBy || ' ' ;
71
+ config . suiteTitleSeparatedBy = config . suiteTitleSeparatedBy || config . suiteTitleSeparedBy ;
59
72
60
- return options ;
73
+ return config ;
61
74
}
62
75
63
76
function updateOptionsForAntMode ( options ) {
0 commit comments