Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to recent js-reporters and mocha #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
});

patch += '<script type="text/javascript">window.process = {argv: "", env: []}; // fake for JsReporters</script>\n';
patch += externalScript('js-reporters/dist/js-reporters.js');
patch += externalScript('circular-json/build/circular-json.js');

Expand Down Expand Up @@ -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();
};

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"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",
"tunnel": "0.0.3"
},
"devDependencies": {
"jshint": "2.5.6",
"mocha": "1.15.1",
"mocha": "3.4.2",
"sinon": "1.17.5"
},
"licenses": [
Expand Down
57 changes: 8 additions & 49 deletions tests/external-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: [
Expand All @@ -96,9 +55,9 @@ var repositories = [
'test/browser/opts.html'
],
expected_results: {
tests: 86,
passed: 78,
failed: 8
tests: 20,
passed: 16,
failed: 4
}
},
{
Expand Down Expand Up @@ -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: [
Expand All @@ -173,9 +132,9 @@ var repositoriesOptional = [
'test/browser/opts.html'
],
expected_results: {
tests: 83,
passed: 77,
failed: 6
tests: 20,
passed: 16,
failed: 4
}
}
];
Expand Down