Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(time): report correct time since Jasmine v2.9.0 #197

Merged
merged 3 commits into from Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/adapter.js
Expand Up @@ -161,6 +161,7 @@ function KarmaReporter (tc, jasmineEnv) {
// Save link on native Date object
// because user can mock it
var _Date = Date
var startTimeCurrentSpec = new _Date().getTime()

/**
* @param suite
Expand Down Expand Up @@ -233,8 +234,8 @@ function KarmaReporter (tc, jasmineEnv) {
currentSuite = currentSuite.parent
}

this.specStarted = function (specResult) {
specResult.startTime = new _Date().getTime()
this.specStarted = function () {
startTimeCurrentSpec = new _Date().getTime()
}

this.specDone = function (specResult) {
Expand All @@ -249,7 +250,7 @@ function KarmaReporter (tc, jasmineEnv) {
pending: specResult.status === 'pending',
success: specResult.failedExpectations.length === 0,
suite: [],
time: skipped ? 0 : new _Date().getTime() - specResult.startTime,
time: skipped ? 0 : new _Date().getTime() - startTimeCurrentSpec,
executedExpectationsCount: specResult.failedExpectations.length + specResult.passedExpectations.length
}

Expand Down
4 changes: 2 additions & 2 deletions test/adapter.spec.js
Expand Up @@ -262,8 +262,8 @@ describe('jasmine adapter', function () {
expect(result.time).toBe(1) // 4 - 3
})

reporter.specStarted(spec.result)
reporter.specDone(spec.result)
reporter.specStarted(Object.assign({}, spec.result))
reporter.specDone(Object.assign({}, spec.result))

expect(karma.result).toHaveBeenCalled()
})
Expand Down