Permit HTMLReporter to render every 250ms
- This is necessary for the user to see spec results fill-in progressively. - There is a slight performance loss. 250 - 500ms seems to deliver the same amount of loss. This is still at parity with Jasmine 1.x
This commit is contained in:
@@ -62,7 +62,7 @@ jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.HtmlReporter = function(_doc, jasmine) {
|
jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.jasmine = jasmine || window.jasmine;
|
this.jasmine = jasmine || window.jasmine;
|
||||||
var doc = _doc || window.document;
|
var doc = _doc || window.document;
|
||||||
@@ -99,8 +99,20 @@ jasmine.HtmlReporter = function(_doc, jasmine) {
|
|||||||
self.reportSpecStarting = function(spec) {
|
self.reportSpecStarting = function(spec) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var lastYieldForRender = 0;
|
||||||
|
var refreshInterval = 250;
|
||||||
|
yieldForRender = yieldForRender || function(fn) {
|
||||||
|
var now = Date.now();
|
||||||
|
var delta = (now - lastYieldForRender);
|
||||||
|
if (delta > refreshInterval) {
|
||||||
|
lastYieldForRender = now;
|
||||||
|
setTimeout(fn, 0);
|
||||||
|
} else {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
self.reportSpecResults = function(result) {
|
self.reportSpecResults = function(result) {
|
||||||
reporterView.specComplete(result);
|
yieldForRender(function() {reporterView.specComplete(result) });
|
||||||
};
|
};
|
||||||
|
|
||||||
self.log = function() {
|
self.log = function() {
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ describe("HtmlReporter", function() {
|
|||||||
env = new jasmine.Env();
|
env = new jasmine.Env();
|
||||||
env.updateInterval = 0;
|
env.updateInterval = 0;
|
||||||
|
|
||||||
|
|
||||||
body = document.createElement("body");
|
body = document.createElement("body");
|
||||||
fakeDocument = { body: body, location: { search: "" } };
|
fakeDocument = { body: body, location: { search: "" } };
|
||||||
htmlReporter = new jasmine.HtmlReporter(fakeDocument);
|
htmlReporter = new jasmine.HtmlReporter(fakeDocument, null, function(fn) { fn() });
|
||||||
});
|
});
|
||||||
|
|
||||||
function fakeSpec(name) {
|
function fakeSpec(name) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
jasmine.HtmlReporter = function(_doc, jasmine) {
|
jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.jasmine = jasmine || window.jasmine;
|
this.jasmine = jasmine || window.jasmine;
|
||||||
var doc = _doc || window.document;
|
var doc = _doc || window.document;
|
||||||
@@ -35,8 +35,20 @@ jasmine.HtmlReporter = function(_doc, jasmine) {
|
|||||||
self.reportSpecStarting = function(spec) {
|
self.reportSpecStarting = function(spec) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var lastYieldForRender = 0;
|
||||||
|
var refreshInterval = 250;
|
||||||
|
yieldForRender = yieldForRender || function(fn) {
|
||||||
|
var now = Date.now();
|
||||||
|
var delta = (now - lastYieldForRender);
|
||||||
|
if (delta > refreshInterval) {
|
||||||
|
lastYieldForRender = now;
|
||||||
|
setTimeout(fn, 0);
|
||||||
|
} else {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
self.reportSpecResults = function(result) {
|
self.reportSpecResults = function(result) {
|
||||||
reporterView.specComplete(result);
|
yieldForRender(function() {reporterView.specComplete(result) });
|
||||||
};
|
};
|
||||||
|
|
||||||
self.log = function() {
|
self.log = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user