Skip to content

Commit b38fe03

Browse files
committed
Reporter: merge QUnit, Mocha, Jasmine2 reporters into one.
1 parent e9a8acf commit b38fe03

File tree

4 files changed

+16
-89
lines changed

4 files changed

+16
-89
lines changed

lib/_patch/mocha-plugin.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/_patch/qunit-plugin.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

lib/_patch/jasmine2-plugin.js renamed to lib/_patch/reporter.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
(function() {
2-
var runner = new JsReporters.JasmineAdapter(jasmine.getEnv());
2+
var runner;
33
var tracebacks = [];
44
var total = 0,
55
passed = 0,
66
failed = 0;
77

8+
if (window.QUnit) {
9+
runner = new JsReporters.QUnitAdapter(QUnit);
10+
} else if (window.jasmine) {
11+
runner = new JsReporters.JasmineAdapter(jasmine.getEnv());
12+
} else if (window.mocha) {
13+
runner = new JsReporters.MochaAdapter(mocha);
14+
} else {
15+
throw new Error('JsReporters: No testing framework was found');
16+
}
17+
818
runner.on('testEnd', function(test) {
919
total = total + 1
1020

@@ -19,7 +29,8 @@
1929
runner.on('runEnd', function(globalSuite) {
2030
var results = {};
2131

22-
results.runtime = globalSuite.runtime;
32+
// TODO Investigate why is the runtime not functioning for Mocha.
33+
results.runtime = (window.mocha) ? 0 : globalSuite.runtime;
2334
results.total = total;
2435
results.passed = passed;
2536
results.failed = failed;

lib/server.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ exports.Server = function Server(bsClient, workers) {
4040
];
4141

4242
var framework_scripts = {
43-
'qunit': ['qunit-plugin.js'],
44-
'jasmine': ['jasmine-jsreporter.js', 'jasmine-plugin.js'],
45-
'jasmine2': ['jasmine2-plugin.js'],
46-
'mocha': ['mocha-plugin.js']
43+
'jasmine': ['jasmine-jsreporter.js', 'jasmine-plugin.js']
4744
};
4845

4946
var filePath = path.relative(process.cwd(), filename);
@@ -64,18 +61,8 @@ exports.Server = function Server(bsClient, workers) {
6461
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
6562
});
6663
patch += '<script type="text/javascript">jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n';
67-
} else if (framework === 'jasmine2') {
68-
framework_scripts['jasmine2'].forEach(function(script) {
69-
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
70-
});
71-
} else if (framework === 'mocha') {
72-
framework_scripts['mocha'].forEach(function(script) {
73-
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
74-
});
75-
} else if (framework === 'qunit') {
76-
framework_scripts['qunit'].forEach(function(script) {
77-
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
78-
});
64+
} else {
65+
patch += '<script type="text/javascript" src="/_patch/reporter.js"></script>\n';
7966
}
8067
patch += '</' + tag_name + '>';
8168
return patch;

0 commit comments

Comments
 (0)