Merge pull request #384 from sheelc/apireporter_execution_time
Add execution time elapsed to JsApiReporter
This commit is contained in:
@@ -30,11 +30,10 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
function HtmlReporter(options) {
|
function HtmlReporter(options) {
|
||||||
var env = options.env || {},
|
var env = options.env || {},
|
||||||
getContainer = options.getContainer,
|
getContainer = options.getContainer,
|
||||||
now = options.now || function() { return new Date().getTime();},
|
|
||||||
createElement = options.createElement,
|
createElement = options.createElement,
|
||||||
createTextNode = options.createTextNode,
|
createTextNode = options.createTextNode,
|
||||||
|
onRaiseExceptionsClick = options.onRaiseExceptionsClick,
|
||||||
results = [],
|
results = [],
|
||||||
startTime,
|
|
||||||
specsExecuted = 0,
|
specsExecuted = 0,
|
||||||
failureCount = 0,
|
failureCount = 0,
|
||||||
pendingSpecCount = 0,
|
pendingSpecCount = 0,
|
||||||
@@ -61,7 +60,6 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
var totalSpecsDefined;
|
var totalSpecsDefined;
|
||||||
this.jasmineStarted = function(options) {
|
this.jasmineStarted = function(options) {
|
||||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||||
startTime = now();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var summary = createDom("div", {className: "summary"});
|
var summary = createDom("div", {className: "summary"});
|
||||||
@@ -122,11 +120,9 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
this.jasmineDone = function(options) {
|
||||||
var elapsed = now() - startTime;
|
|
||||||
|
|
||||||
var banner = find(".banner");
|
var banner = find(".banner");
|
||||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + elapsed / 1000 + "s"));
|
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + options.executionTime / 1000 + "s"));
|
||||||
|
|
||||||
var alert = find(".alert");
|
var alert = find(".alert");
|
||||||
|
|
||||||
@@ -141,7 +137,7 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
var checkbox = find("input");
|
var checkbox = find("input");
|
||||||
|
|
||||||
checkbox.checked = !env.catchingExceptions();
|
checkbox.checked = !env.catchingExceptions();
|
||||||
checkbox.onclick = options.onRaiseExceptionsClick;
|
checkbox.onclick = onRaiseExceptionsClick;
|
||||||
|
|
||||||
if (specsExecuted < totalSpecsDefined) {
|
if (specsExecuted < totalSpecsDefined) {
|
||||||
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
||||||
|
|||||||
@@ -307,7 +307,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
function Env(options) {
|
function Env(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var self = this;
|
var self = this;
|
||||||
var global = options.global || j$.getGlobal();
|
var global = options.global || j$.getGlobal(),
|
||||||
|
now = options.now || function() { return new Date().getTime(); };
|
||||||
|
|
||||||
var catchExceptions = true;
|
var catchExceptions = true;
|
||||||
|
|
||||||
@@ -497,10 +498,13 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.execute = function() {
|
this.execute = function() {
|
||||||
|
var startTime = now();
|
||||||
this.reporter.jasmineStarted({
|
this.reporter.jasmineStarted({
|
||||||
totalSpecsDefined: totalSpecsDefined
|
totalSpecsDefined: totalSpecsDefined
|
||||||
});
|
});
|
||||||
this.topSuite.execute(this.reporter.jasmineDone);
|
this.topSuite.execute(function() {
|
||||||
|
self.reporter.jasmineDone({executionTime: now() - startTime});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,8 +659,11 @@ getJasmineRequireObj().JsApiReporter = function() {
|
|||||||
status = 'started';
|
status = 'started';
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
var executionTime;
|
||||||
|
|
||||||
|
this.jasmineDone = function(options) {
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
|
executionTime = options.executionTime;
|
||||||
status = 'done';
|
status = 'done';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -697,6 +704,10 @@ getJasmineRequireObj().JsApiReporter = function() {
|
|||||||
return specs;
|
return specs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.executionTime = function() {
|
||||||
|
return executionTime;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsApiReporter;
|
return JsApiReporter;
|
||||||
|
|||||||
@@ -69,20 +69,15 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a summary when done (singluar spec and time)", function() {
|
it("reports a summary when done (singluar spec and time)", function() {
|
||||||
var fakeNow = jasmine.createSpy('fake Date.now'),
|
var reporter = new j$.ConsoleReporter({
|
||||||
reporter = new j$.ConsoleReporter({
|
|
||||||
print: out.print,
|
print: out.print,
|
||||||
now: fakeNow
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fakeNow.andReturn(500);
|
|
||||||
|
|
||||||
reporter.jasmineStarted();
|
reporter.jasmineStarted();
|
||||||
reporter.specDone({status: "passed"});
|
reporter.specDone({status: "passed"});
|
||||||
fakeNow.andReturn(1500);
|
|
||||||
|
|
||||||
out.clear();
|
out.clear();
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({executionTime: 1000});
|
||||||
|
|
||||||
expect(out.getOutput()).toMatch(/1 spec, 0 failures/);
|
expect(out.getOutput()).toMatch(/1 spec, 0 failures/);
|
||||||
expect(out.getOutput()).not.toMatch(/0 pending specs/);
|
expect(out.getOutput()).not.toMatch(/0 pending specs/);
|
||||||
@@ -90,13 +85,10 @@ describe("ConsoleReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("reports a summary when done (pluralized specs and seconds)", function() {
|
it("reports a summary when done (pluralized specs and seconds)", function() {
|
||||||
var fakeNow = jasmine.createSpy('fake Date.now'),
|
var reporter = new j$.ConsoleReporter({
|
||||||
reporter = new j$.ConsoleReporter({
|
|
||||||
print: out.print,
|
print: out.print,
|
||||||
now: fakeNow
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fakeNow.andReturn(500);
|
|
||||||
reporter.jasmineStarted();
|
reporter.jasmineStarted();
|
||||||
reporter.specDone({status: "passed"});
|
reporter.specDone({status: "passed"});
|
||||||
reporter.specDone({status: "pending"});
|
reporter.specDone({status: "pending"});
|
||||||
@@ -117,8 +109,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
out.clear();
|
out.clear();
|
||||||
|
|
||||||
fakeNow.andReturn(600);
|
reporter.jasmineDone({executionTime: 100});
|
||||||
reporter.jasmineDone();
|
|
||||||
|
|
||||||
expect(out.getOutput()).toMatch(/3 specs, 1 failure, 1 pending spec/);
|
expect(out.getOutput()).toMatch(/3 specs, 1 failure, 1 pending spec/);
|
||||||
expect(out.getOutput()).toMatch("Finished in 0.1 seconds\n");
|
expect(out.getOutput()).toMatch("Finished in 0.1 seconds\n");
|
||||||
@@ -148,7 +139,7 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
out.clear();
|
out.clear();
|
||||||
|
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
expect(out.getOutput()).toMatch(/foo bar baz/);
|
expect(out.getOutput()).toMatch(/foo bar baz/);
|
||||||
});
|
});
|
||||||
@@ -160,7 +151,7 @@ describe("ConsoleReporter", function() {
|
|||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -167,8 +167,9 @@ describe("Env (integration)", function() {
|
|||||||
|
|
||||||
// TODO: something is wrong with this spec
|
// TODO: something is wrong with this spec
|
||||||
it("should report as expected", function() {
|
it("should report as expected", function() {
|
||||||
var env = new j$.Env(),
|
var fakeNow = jasmine.createSpy('fake Date.now'),
|
||||||
reporter = jasmine.createSpyObj('fakeReproter', [
|
env = new j$.Env({now: fakeNow}),
|
||||||
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
||||||
"jasmineStarted",
|
"jasmineStarted",
|
||||||
"jasmineDone",
|
"jasmineDone",
|
||||||
"suiteStarted",
|
"suiteStarted",
|
||||||
@@ -177,6 +178,9 @@ describe("Env (integration)", function() {
|
|||||||
"specDone"
|
"specDone"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
fakeNow.andReturn(500);
|
||||||
|
reporter.suiteDone.andCallFake(function() { fakeNow.andReturn(1500); });
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
|
|
||||||
env.describe("A Suite", function() {
|
env.describe("A Suite", function() {
|
||||||
@@ -200,7 +204,9 @@ describe("Env (integration)", function() {
|
|||||||
});
|
});
|
||||||
var suiteResult = reporter.suiteStarted.calls[0].args[0];
|
var suiteResult = reporter.suiteStarted.calls[0].args[0];
|
||||||
expect(suiteResult.description).toEqual("A Suite");
|
expect(suiteResult.description).toEqual("A Suite");
|
||||||
expect(reporter.jasmineDone).toHaveBeenCalled();
|
expect(reporter.jasmineDone).toHaveBeenCalledWith({
|
||||||
|
executionTime: 1000
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be possible to get full name from a spec", function() {
|
it("should be possible to get full name from a spec", function() {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ describe("JsApiReporter", function() {
|
|||||||
expect(reporter.finished).toBe(false);
|
expect(reporter.finished).toBe(false);
|
||||||
|
|
||||||
reporter.jasmineStarted();
|
reporter.jasmineStarted();
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
expect(reporter.finished).toBe(true);
|
expect(reporter.finished).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -123,7 +123,7 @@ describe("JsApiReporter", function() {
|
|||||||
it("reports 'done' when Jasmine is done", function() {
|
it("reports 'done' when Jasmine is done", function() {
|
||||||
var reporter = new j$.JsApiReporter();
|
var reporter = new j$.JsApiReporter();
|
||||||
|
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
expect(reporter.status()).toEqual('done');
|
expect(reporter.status()).toEqual('done');
|
||||||
});
|
});
|
||||||
@@ -178,4 +178,22 @@ describe("JsApiReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#executionTime", function() {
|
||||||
|
var reporter;
|
||||||
|
beforeEach(function() {
|
||||||
|
reporter = new j$.JsApiReporter();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return the time it took the specs to run, in ms", function() {
|
||||||
|
reporter.jasmineDone({executionTime: 1000});
|
||||||
|
expect(reporter.executionTime()).toEqual(1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when the specs haven't finished being run", function() {
|
||||||
|
it("should return undefined", function() {
|
||||||
|
expect(reporter.executionTime()).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -118,23 +118,19 @@ describe("New HtmlReporter", function() {
|
|||||||
describe("when Jasmine is done", function() {
|
describe("when Jasmine is done", function() {
|
||||||
it("reports the run time", function() {
|
it("reports the run time", function() {
|
||||||
var env = new jasmine.Env(),
|
var env = new jasmine.Env(),
|
||||||
fakeNow = jasmine.createSpy('fake Date.now'),
|
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
getContainer = function() { return container; },
|
getContainer = function() { return container; },
|
||||||
reporter = new jasmine.HtmlReporter({
|
reporter = new jasmine.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
now: fakeNow,
|
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
fakeNow.andReturn(500);
|
|
||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
fakeNow.andReturn(600);
|
reporter.jasmineDone({executionTime: 100});
|
||||||
reporter.jasmineDone();
|
|
||||||
|
|
||||||
var duration = container.querySelector(".banner .duration");
|
var duration = container.querySelector(".banner .duration");
|
||||||
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
||||||
@@ -197,7 +193,7 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
reporter.suiteDone({id: 1});
|
reporter.suiteDone({id: 1});
|
||||||
|
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
var summary = container.querySelector(".summary");
|
var summary = container.querySelector(".summary");
|
||||||
|
|
||||||
expect(summary.childNodes.length).toEqual(1);
|
expect(summary.childNodes.length).toEqual(1);
|
||||||
@@ -247,7 +243,7 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var raisingExceptionsUI = container.querySelector(".raise");
|
var raisingExceptionsUI = container.querySelector(".raise");
|
||||||
expect(raisingExceptionsUI.checked).toBe(false);
|
expect(raisingExceptionsUI.checked).toBe(false);
|
||||||
@@ -272,7 +268,7 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
env.catchExceptions(false);
|
env.catchExceptions(false);
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var raisingExceptionsUI = container.querySelector(".raise");
|
var raisingExceptionsUI = container.querySelector(".raise");
|
||||||
expect(raisingExceptionsUI.checked).toBe(true);
|
expect(raisingExceptionsUI.checked).toBe(true);
|
||||||
@@ -298,7 +294,7 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var input = container.querySelector(".raise");
|
var input = container.querySelector(".raise");
|
||||||
input.click();
|
input.click();
|
||||||
@@ -333,7 +329,7 @@ describe("New HtmlReporter", function() {
|
|||||||
fullName: "A Suite inner suite with another spec",
|
fullName: "A Suite inner suite with another spec",
|
||||||
status: "passed"
|
status: "passed"
|
||||||
});
|
});
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the specs counts", function() {
|
it("reports the specs counts", function() {
|
||||||
@@ -378,7 +374,7 @@ describe("New HtmlReporter", function() {
|
|||||||
fullName: "A Suite with a spec",
|
fullName: "A Suite with a spec",
|
||||||
status: "pending"
|
status: "pending"
|
||||||
});
|
});
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the pending specs count", function() {
|
it("reports the pending specs count", function() {
|
||||||
@@ -429,7 +425,7 @@ describe("New HtmlReporter", function() {
|
|||||||
};
|
};
|
||||||
reporter.specStarted(failingResult);
|
reporter.specStarted(failingResult);
|
||||||
reporter.specDone(failingResult);
|
reporter.specDone(failingResult);
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports the specs counts", function() {
|
it("reports the specs counts", function() {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
var print = options.print,
|
var print = options.print,
|
||||||
showColors = options.showColors || false,
|
showColors = options.showColors || false,
|
||||||
onComplete = options.onComplete || function() {},
|
onComplete = options.onComplete || function() {},
|
||||||
now = options.now || function() { return new Date().getTime();},
|
|
||||||
startTime = 0,
|
|
||||||
specCount,
|
specCount,
|
||||||
failureCount,
|
failureCount,
|
||||||
failedSpecs = [],
|
failedSpecs = [],
|
||||||
@@ -17,7 +15,6 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
startTime = now();
|
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
failureCount = 0;
|
failureCount = 0;
|
||||||
pendingCount = 0;
|
pendingCount = 0;
|
||||||
@@ -25,9 +22,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
printNewline();
|
printNewline();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
this.jasmineDone = function(options) {
|
||||||
var elapsed = now() - startTime;
|
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
for (var i = 0; i < failedSpecs.length; i++) {
|
for (var i = 0; i < failedSpecs.length; i++) {
|
||||||
specFailureDetails(failedSpecs[i]);
|
specFailureDetails(failedSpecs[i]);
|
||||||
@@ -44,7 +39,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
print(specCounts);
|
print(specCounts);
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
var seconds = elapsed / 1000;
|
var seconds = options.executionTime / 1000;
|
||||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
var print = options.print,
|
var print = options.print,
|
||||||
showColors = options.showColors || false,
|
showColors = options.showColors || false,
|
||||||
onComplete = options.onComplete || function() {},
|
onComplete = options.onComplete || function() {},
|
||||||
now = options.now || function() { return new Date().getTime();},
|
|
||||||
startTime = 0,
|
|
||||||
specCount,
|
specCount,
|
||||||
failureCount,
|
failureCount,
|
||||||
failedSpecs = [],
|
failedSpecs = [],
|
||||||
@@ -52,7 +50,6 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
startTime = now();
|
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
failureCount = 0;
|
failureCount = 0;
|
||||||
pendingCount = 0;
|
pendingCount = 0;
|
||||||
@@ -60,9 +57,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
printNewline();
|
printNewline();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
this.jasmineDone = function(options) {
|
||||||
var elapsed = now() - startTime;
|
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
for (var i = 0; i < failedSpecs.length; i++) {
|
for (var i = 0; i < failedSpecs.length; i++) {
|
||||||
specFailureDetails(failedSpecs[i]);
|
specFailureDetails(failedSpecs[i]);
|
||||||
@@ -79,7 +74,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
print(specCounts);
|
print(specCounts);
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
var seconds = elapsed / 1000;
|
var seconds = options.executionTime / 1000;
|
||||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
function Env(options) {
|
function Env(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var self = this;
|
var self = this;
|
||||||
var global = options.global || j$.getGlobal();
|
var global = options.global || j$.getGlobal(),
|
||||||
|
now = options.now || function() { return new Date().getTime(); };
|
||||||
|
|
||||||
var catchExceptions = true;
|
var catchExceptions = true;
|
||||||
|
|
||||||
@@ -192,10 +193,13 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.execute = function() {
|
this.execute = function() {
|
||||||
|
var startTime = now();
|
||||||
this.reporter.jasmineStarted({
|
this.reporter.jasmineStarted({
|
||||||
totalSpecsDefined: totalSpecsDefined
|
totalSpecsDefined: totalSpecsDefined
|
||||||
});
|
});
|
||||||
this.topSuite.execute(this.reporter.jasmineDone);
|
this.topSuite.execute(function() {
|
||||||
|
self.reporter.jasmineDone({executionTime: now() - startTime});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ getJasmineRequireObj().JsApiReporter = function() {
|
|||||||
status = 'started';
|
status = 'started';
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
var executionTime;
|
||||||
|
|
||||||
|
this.jasmineDone = function(options) {
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
|
executionTime = options.executionTime;
|
||||||
status = 'done';
|
status = 'done';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,6 +56,10 @@ getJasmineRequireObj().JsApiReporter = function() {
|
|||||||
return specs;
|
return specs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.executionTime = function() {
|
||||||
|
return executionTime;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsApiReporter;
|
return JsApiReporter;
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
function HtmlReporter(options) {
|
function HtmlReporter(options) {
|
||||||
var env = options.env || {},
|
var env = options.env || {},
|
||||||
getContainer = options.getContainer,
|
getContainer = options.getContainer,
|
||||||
now = options.now || function() { return new Date().getTime();},
|
|
||||||
createElement = options.createElement,
|
createElement = options.createElement,
|
||||||
createTextNode = options.createTextNode,
|
createTextNode = options.createTextNode,
|
||||||
|
onRaiseExceptionsClick = options.onRaiseExceptionsClick,
|
||||||
results = [],
|
results = [],
|
||||||
startTime,
|
|
||||||
specsExecuted = 0,
|
specsExecuted = 0,
|
||||||
failureCount = 0,
|
failureCount = 0,
|
||||||
pendingSpecCount = 0,
|
pendingSpecCount = 0,
|
||||||
@@ -33,7 +32,6 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
var totalSpecsDefined;
|
var totalSpecsDefined;
|
||||||
this.jasmineStarted = function(options) {
|
this.jasmineStarted = function(options) {
|
||||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||||
startTime = now();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var summary = createDom("div", {className: "summary"});
|
var summary = createDom("div", {className: "summary"});
|
||||||
@@ -94,11 +92,9 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function() {
|
this.jasmineDone = function(options) {
|
||||||
var elapsed = now() - startTime;
|
|
||||||
|
|
||||||
var banner = find(".banner");
|
var banner = find(".banner");
|
||||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + elapsed / 1000 + "s"));
|
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + options.executionTime / 1000 + "s"));
|
||||||
|
|
||||||
var alert = find(".alert");
|
var alert = find(".alert");
|
||||||
|
|
||||||
@@ -113,7 +109,7 @@ jasmineRequire.HtmlReporter = function() {
|
|||||||
var checkbox = find("input");
|
var checkbox = find("input");
|
||||||
|
|
||||||
checkbox.checked = !env.catchingExceptions();
|
checkbox.checked = !env.catchingExceptions();
|
||||||
checkbox.onclick = options.onRaiseExceptionsClick;
|
checkbox.onclick = onRaiseExceptionsClick;
|
||||||
|
|
||||||
if (specsExecuted < totalSpecsDefined) {
|
if (specsExecuted < totalSpecsDefined) {
|
||||||
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
||||||
|
|||||||
Reference in New Issue
Block a user