feat(result.duration): report test duration in ms
Wrap spec start/complete in Timer start/elapsed. configuration.timeSpecDuration = false will disable feature. * Add Suite result.duration, elapsed time in ms * Remove timeSpecDuration option. * Respond to review, use noopTimer
This commit is contained in:
@@ -207,7 +207,8 @@ describe("Spec", function() {
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: ''
|
||||
pendingReason: '',
|
||||
duration: null,
|
||||
}, 'things');
|
||||
});
|
||||
|
||||
@@ -242,6 +243,22 @@ describe("Spec", function() {
|
||||
expect(done).toHaveBeenCalledWith(jasmine.any(jasmineUnderTest.StopExecutionError));
|
||||
});
|
||||
|
||||
it("should report the duration of the test", function() {
|
||||
var done = jasmine.createSpy('done callback'),
|
||||
timer = jasmine.createSpyObj('timer', {'start': null, elapsed: 77000}),
|
||||
spec = new jasmineUnderTest.Spec({
|
||||
queueableFn: { fn: jasmine.createSpy("spec body")},
|
||||
catchExceptions: function() { return false; },
|
||||
resultCallback: function() {},
|
||||
queueRunnerFactory: function(attrs) {
|
||||
attrs.onComplete();
|
||||
},
|
||||
timer: timer,
|
||||
});
|
||||
spec.execute(done);
|
||||
expect(spec.result.duration).toBe(77000);
|
||||
});
|
||||
|
||||
it("#status returns passing by default", function() {
|
||||
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
||||
expect(spec.status()).toBe('passed');
|
||||
|
||||
@@ -111,6 +111,19 @@ describe("Suite", function() {
|
||||
expect(suite.getResult().failedExpectations).toEqual([]);
|
||||
});
|
||||
|
||||
it("calls timer to compute duration", function(){
|
||||
var env = new jasmineUnderTest.Env(),
|
||||
suite = new jasmineUnderTest.Suite({
|
||||
env: env,
|
||||
id: 456,
|
||||
description: "I am a suite",
|
||||
timer: jasmine.createSpyObj('timer', {'start': null, elapsed: 77000}),
|
||||
});
|
||||
suite.startTimer();
|
||||
suite.endTimer();
|
||||
expect(suite.getResult().duration).toEqual(77000);
|
||||
});
|
||||
|
||||
describe('#sharedUserContext', function() {
|
||||
beforeEach(function() {
|
||||
this.suite = new jasmineUnderTest.Suite({});
|
||||
|
||||
@@ -1436,6 +1436,9 @@ describe("Env integration", function() {
|
||||
status: 'pending'
|
||||
}));
|
||||
|
||||
var suiteDone = reporter.suiteDone.calls.argsFor(0)[0];
|
||||
expect(typeof suiteDone.duration).toBe('number');
|
||||
|
||||
var suiteResult = reporter.suiteStarted.calls.argsFor(0)[0];
|
||||
expect(suiteResult.description).toEqual("A Suite");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user