Skip to content

Commit

Permalink
Merge pull request #86 from browserstack/pr/83
Browse files Browse the repository at this point in the history
Pr/83
  • Loading branch information
nakula committed May 21, 2014
2 parents 7561403 + 62e940f commit 0f805d7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,25 @@ exports.Server = function Server(bsClient, workers) {
pathMatches = (filePath == config.test_path);
}
if (pathMatches && mimeType === 'text/html') {
var matcher = /(.*)<\/head>/;
var framework = config['test_framework'];
var tag_name = (framework === "mocha") ? "head" : "body";
var matcher = new RegExp("(.*)<\/" + tag_name + ">"); ///(.*)<\/body>/;
var patch = "$1";
scripts.forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});

// adding framework scripts
if (config['test_framework'] && config['test_framework'] == "jasmine") {
if (framework === "jasmine") {
framework_scripts['jasmine'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
patch += "<script type='text/javascript'>jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n";
} else if (config['test_framework'] && config['test_framework'] == "jasmine2") {
} else if (framework === "jasmine2") {
framework_scripts['jasmine2'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
} else if (config['test_framework'] && config['test_framework'] == "mocha") {
} else if (framework === "mocha") {
framework_scripts['mocha'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
Expand All @@ -118,7 +120,7 @@ exports.Server = function Server(bsClient, workers) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
}
patch += "</head>";
patch += "</" + tag_name + ">";

file = file.replace(matcher, patch);
}
Expand Down

0 comments on commit 0f805d7

Please sign in to comment.