Merge branch 'forEach-ie-fix' of git://github.com/pimterry/grunt-contrib-jasmine into pimterry-forEach-ie-fix
* 'forEach-ie-fix' of git://github.com/pimterry/grunt-contrib-jasmine: Added explicit map implementation too, for further IE compatibility Whoops, stripped leftover semi-colon that makes jshint unhappy Switched forEach out to for(var; < length; ++) to allow compatibility with other browsers
This commit is contained in:
commit
1d71a9be02
@ -82,9 +82,17 @@ phantom.sendMessage = function() {
|
|||||||
return this.results_[specId];
|
return this.results_[specId];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function map(values, f) {
|
||||||
|
var result = [];
|
||||||
|
for (var ii = 0; ii < values.length; ii++) {
|
||||||
|
result.push(f(values[ii]));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
PhantomReporter.prototype.reportRunnerResults = function(runner) {
|
PhantomReporter.prototype.reportRunnerResults = function(runner) {
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
var specIds = runner.specs().map(function(a){return a.id;});
|
var specIds = map(runner.specs(), function(a){return a.id;});
|
||||||
var summary = this.resultsForSpecs(specIds);
|
var summary = this.resultsForSpecs(specIds);
|
||||||
phantom.sendMessage('jasmine.reportRunnerResults',summary);
|
phantom.sendMessage('jasmine.reportRunnerResults',summary);
|
||||||
phantom.sendMessage('jasmine.reportJUnitResults', this.generateJUnitSummary(runner));
|
phantom.sendMessage('jasmine.reportJUnitResults', this.generateJUnitSummary(runner));
|
||||||
@ -155,14 +163,15 @@ phantom.sendMessage = function() {
|
|||||||
this.results_[spec.id] = results;
|
this.results_[spec.id] = results;
|
||||||
|
|
||||||
// Quick hack to alleviate cyclical object breaking JSONification.
|
// Quick hack to alleviate cyclical object breaking JSONification.
|
||||||
results.messages.forEach(function(item){
|
for (var ii = 0; ii < results.messages.length; ii++) {
|
||||||
|
var item = results.messages[ii];
|
||||||
if (item.expected) {
|
if (item.expected) {
|
||||||
item.expected = stringify(item.expected);
|
item.expected = stringify(item.expected);
|
||||||
}
|
}
|
||||||
if (item.actual) {
|
if (item.actual) {
|
||||||
item.actual = stringify(item.actual);
|
item.actual = stringify(item.actual);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
phantom.sendMessage( 'jasmine.reportSpecResults', spec.id, results, this.getFullName(spec));
|
phantom.sendMessage( 'jasmine.reportSpecResults', spec.id, results, this.getFullName(spec));
|
||||||
};
|
};
|
||||||
@ -222,18 +231,20 @@ phantom.sendMessage = function() {
|
|||||||
|
|
||||||
PhantomReporter.prototype.generateJUnitSummary = function(runner) {
|
PhantomReporter.prototype.generateJUnitSummary = function(runner) {
|
||||||
var consolidatedSuites = {},
|
var consolidatedSuites = {},
|
||||||
suites = runner.suites().map(function(suite) {
|
suites = map(runner.suites(), function(suite) {
|
||||||
var failures = 0;
|
var failures = 0;
|
||||||
|
|
||||||
var testcases = suite.specs().map(function(spec) {
|
var testcases = map(suite.specs(), function(spec) {
|
||||||
var failureMessages = [];
|
var failureMessages = [];
|
||||||
if (spec.results().failedCount) {
|
if (spec.results().failedCount) {
|
||||||
failures++;
|
failures++;
|
||||||
spec.results().items_.forEach(function(expectation) {
|
var resultsItems = spec.results().items_;
|
||||||
|
for (var ii = 0; ii < resultsItems; ii++) {
|
||||||
|
var expectation = resultsItems[ii];
|
||||||
if (!expectation.passed()) {
|
if (!expectation.passed()) {
|
||||||
failureMessages.push(expectation.message);
|
failureMessages.push(expectation.message);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
assertions: spec.results().items_.length,
|
assertions: spec.results().items_.length,
|
||||||
|
Loading…
Reference in New Issue
Block a user