Previously, suite duration was always reported as 0 and spec duration was always reported as null. Suites always used a no-op timer, and specs set their result.duration after the result had already been sent to reporters. Fixes #1676.
25 lines
435 B
JavaScript
25 lines
435 B
JavaScript
getJasmineRequireObj().Timer = function() {
|
|
var defaultNow = (function(Date) {
|
|
return function() {
|
|
return new Date().getTime();
|
|
};
|
|
})(Date);
|
|
|
|
function Timer(options) {
|
|
options = options || {};
|
|
|
|
var now = options.now || defaultNow,
|
|
startTime;
|
|
|
|
this.start = function() {
|
|
startTime = now();
|
|
};
|
|
|
|
this.elapsed = function() {
|
|
return now() - startTime;
|
|
};
|
|
}
|
|
|
|
return Timer;
|
|
};
|