Skip to content

Commit 4644eed

Browse files
committed
JasmineReporter: update Jasmine reporter based on the js-reporters adapter.
1 parent 8c88f26 commit 4644eed

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

lib/_patch/jasmine2-plugin.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
(function() {
2-
var checker = setInterval(function() {
3-
if (!jasmine.running) {
4-
var results = {};
5-
var specs = jsApiReporter.specs();
6-
results.runtime = jsApiReporter.executionTime();
7-
results.total = 0;
8-
results.passed = 0;
9-
results.failed = 0;
10-
results.tracebacks = [];
2+
var runner = new JsReporters.JasmineAdapter(jasmine.getEnv());
3+
var tracebacks = [];
4+
var total = 0,
5+
passed = 0,
6+
failed = 0;
117

12-
for (var spec in specs) {
13-
if (specs[spec].status === 'passed') {
14-
results.passed++;
15-
} else {
16-
results.tracebacks.push(specs[spec].description);
17-
results.failed++;
18-
}
19-
}
8+
runner.on('testEnd', function(test) {
9+
total = total + 1
2010

21-
results.total = results.passed + results.failed;
22-
results.url = window.location.pathname;
23-
BrowserStack.post('/_report', results, function(){});
24-
}
25-
clearInterval(checker);
26-
}, 1000);
11+
passed = passed + (test.status === 'passed' ? 1 : 0);
12+
failed = failed + (test.status === 'failed' ? 1 : 0);
13+
14+
test.errors.forEach(function(error) {
15+
tracebacks.push(error)
16+
});
17+
});
18+
19+
runner.on('runEnd', function(globalSuite) {
20+
var results = {};
21+
22+
results.runtime = globalSuite.runtime;
23+
results.total = total;
24+
results.passed = passed;
25+
results.failed = failed;
26+
results.tracebacks = tracebacks;
27+
results.url = window.location.pathname;
28+
29+
BrowserStack.post("/_report", results, function() {});
30+
});
2731
})();
2832

lib/server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ exports.Server = function Server(bsClient, workers) {
6363
framework_scripts['jasmine'].forEach(function(script) {
6464
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';
6565
});
66-
patch += '<script type="text/javascript">jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n';
6766
} else if (framework === 'jasmine2') {
6867
framework_scripts['jasmine2'].forEach(function(script) {
6968
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n';

0 commit comments

Comments
 (0)