@@ -92,23 +92,25 @@ exports.Server = function Server(bsClient, workers) {
9292 pathMatches = ( filePath == config . test_path ) ;
9393 }
9494 if ( pathMatches && mimeType === 'text/html' ) {
95- var matcher = / ( .* ) < \/ b o d y > / ;
95+ var framework = config [ 'test_framework' ] ;
96+ var tag_name = ( framework === "mocha" ) ? "head" : "body" ;
97+ var matcher = new RegExp ( "(.*)<\/" + tag_name + ">" ) ; ///(.*)<\/body>/;
9698 var patch = "$1" ;
9799 scripts . forEach ( function ( script ) {
98100 patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n" ;
99101 } ) ;
100102
101103 // adding framework scripts
102- if ( config [ 'test_framework' ] && config [ 'test_framework' ] == "jasmine" ) {
104+ if ( framework = == "jasmine" ) {
103105 framework_scripts [ 'jasmine' ] . forEach ( function ( script ) {
104106 patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n" ;
105107 } ) ;
106108 patch += "<script type='text/javascript'>jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n" ;
107- } else if ( config [ 'test_framework' ] && config [ 'test_framework' ] == "jasmine2" ) {
109+ } else if ( framework = == "jasmine2" ) {
108110 framework_scripts [ 'jasmine2' ] . forEach ( function ( script ) {
109111 patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n" ;
110112 } ) ;
111- } else if ( config [ 'test_framework' ] && config [ 'test_framework' ] == "mocha" ) {
113+ } else if ( framework = == "mocha" ) {
112114 framework_scripts [ 'mocha' ] . forEach ( function ( script ) {
113115 patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n" ;
114116 } ) ;
@@ -118,7 +120,7 @@ exports.Server = function Server(bsClient, workers) {
118120 patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n" ;
119121 } ) ;
120122 }
121- patch += "</body >" ;
123+ patch += "</" + tag_name + " >";
122124
123125 file = file . replace ( matcher , patch ) ;
124126 }
0 commit comments