diff --git a/lib/server.js b/lib/server.js
index 5ee0af7..dc484d4 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -65,12 +65,13 @@ exports.Server = function Server(bsClient, workers, config, callback) {
if (pathMatches) {
var framework = config['test_framework'];
var tag_name = (framework === 'mocha') ? 'head' : 'body';
- var patch = '$1';
+ var patch = '';
scripts.forEach(function(script) {
patch += '\n';
});
+ patch += '\n';
patch += externalScript('js-reporters/dist/js-reporters.js');
patch += externalScript('circular-json/build/circular-json.js');
@@ -99,11 +100,11 @@ exports.Server = function Server(bsClient, workers, config, callback) {
'Content-Type': 'text/html; charset=utf-8'
});
var tag_name = (config['test_framework'] === 'mocha') ? 'head' : 'body';
- var matcher = new RegExp('(.*)<\/' + tag_name + '>'); ///(.*)<\/body>/;
+ var tag = '' + tag_name + '>';
+ var parts = data.split(tag);
var patch = getReporterPatch();
- data = data.replace(matcher, patch);
-
- response.write(data);
+ parts[0] += patch;
+ response.write(parts.join(tag));
response.end();
};
@@ -355,7 +356,7 @@ exports.Server = function Server(bsClient, workers, config, callback) {
} catch (e) {
query = body;
}
-
+
logger.trace('[%s] _log', ((uuid && workers[uuid]) || {}).id, query);
var logged = false;
diff --git a/package.json b/package.json
index 6edb249..c3ec3b9 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"browserstack": "1.3.0",
"chalk": "0.4.0",
"circular-json": "0.3.1",
- "js-reporters": "1.1.0",
+ "js-reporters": "1.2.0",
"mime": "1.3.4",
"resolve": "1.1.7",
"send": "0.13.0",
@@ -19,7 +19,7 @@
},
"devDependencies": {
"jshint": "2.5.6",
- "mocha": "1.15.1",
+ "mocha": "3.4.2",
"sinon": "1.17.5"
},
"licenses": [
diff --git a/tests/external-tests.js b/tests/external-tests.js
index afc6120..9bc23ba 100755
--- a/tests/external-tests.js
+++ b/tests/external-tests.js
@@ -13,47 +13,6 @@ var runnerPath = path.resolve(path.join(__dirname, '..', 'bin', 'runner.js'));
var testHome = path.resolve(__dirname);
process.chdir(testHome);
-/**
- * Mocha v2.4.5 - to change with another Mocha version or
- * something with Mocha tests
- *
- * index.html - 22 tests, 18 passed, 4 failed -> one test is displayed twice,
- * so they are displayed 5 failing tests, but counted only 4
- * large.html - 64 tests, 60 passed, 4 failed -> only 2 tests are failing, but
- * they are displayed twice
- * opts.html - 8 tests, 2 passed, 6 failed -> only 3 tests are failing, but
- * they are displayed twice
- *
- * By "displayed" it is referred the Mocha HTML Reporter.
- *
- * From the above explanations it is clear that there are some inconsistencies,
- * also because Mocha's HTML Reporter counted number of tests does not match
- * the number of displyed tests.
- *
- * The cause is (snippet from Mocha's HTML reporter):
- *
- * runner.on('fail', function(test) {
- * // For type = 'test' its possible that the test failed due to multiple
- * // done() calls. So report the issue here.
- * if (test.type === 'hook'
- * || test.type === 'test') {
- * runner.emit('test end', test);
- * }
- * });
- *
- * This is why failed tests are displayed twice...
- *
- * The JsReporters is counting the tests on the "test end" event, that's why
- * it is capturing the failing tests twice, in the "index.html" it does not
- * capture everything, because there is an async test, which failure is
- * triggered after a timeout and the JsReporters is not waiting, because
- * it cannot know how much to wait.
- *
- *
- * This been said, the JsReporter MochaAdapter is functioning well, this
- * version of Mocha is not reliable and should be changed.
- */
-
var repositories = [
{
name: 'qunit',
@@ -79,7 +38,7 @@ var repositories = [
},
{
name: 'mocha',
- tag: 'v2.4.5',
+ tag: 'v3.4.2',
url: 'https://github.com/mochajs/mocha.git',
test_framework: 'mocha',
browsers: [
@@ -96,9 +55,9 @@ var repositories = [
'test/browser/opts.html'
],
expected_results: {
- tests: 86,
- passed: 78,
- failed: 8
+ tests: 20,
+ passed: 16,
+ failed: 4
}
},
{
@@ -156,7 +115,7 @@ var repositories = [
var repositoriesOptional = [
{
name: 'mocha',
- tag: '1.21.5',
+ tag: 'v3.4.2',
url: 'https://github.com/mochajs/mocha.git',
test_framework: 'mocha',
browsers: [
@@ -173,9 +132,9 @@ var repositoriesOptional = [
'test/browser/opts.html'
],
expected_results: {
- tests: 83,
- passed: 77,
- failed: 6
+ tests: 20,
+ passed: 16,
+ failed: 4
}
}
];