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:
johnjbarton
2019-03-06 09:34:23 -08:00
parent 7c0f013003
commit a8c2399dd8
6 changed files with 57 additions and 6 deletions

View File

@@ -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');