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(adapter): do not emit debug url unless in a browser #263

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

johnjbarton
Copy link
Contributor

Surprise: someone uses karma-jasmine with native=script.
Fixes #262

@johnjbarton johnjbarton requested a review from kyliau February 8, 2020 03:23
src/adapter.js Outdated
@@ -247,8 +247,10 @@ function KarmaReporter (tc, jasmineEnv) {
result.log.push(formatFailedStep(steps[i]))
}

// Report the name of fhe failing spec so the reporter can emit a debug url.
result.debug_url = debugUrl(specResult.fullName)
if (window && window.location && window.location.origin) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that this code will run in Node?
According to #262 that doesn't seem like the case.
window is still defined, but window.location is not, because the error message was

Cannot read property 'origin' of undefined

when trying to access window.location.origin

I'm asking because the check for 'window' done this way will actually throw a ReferenceError in Node

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course I don't know how this error can happen. But you are completely correct, so I used typeof.

Surprise: someone uses karma-jasmine with native=script.
Fixes karma-runner#262
@johnjbarton johnjbarton merged commit 9bcce88 into karma-runner:master Feb 11, 2020
karmarunnerbot pushed a commit that referenced this pull request Feb 11, 2020
## [3.1.1](v3.1.0...v3.1.1) (2020-02-11)

### Bug Fixes

* **adapter:** do not emit debug url unless in a browser ([#263](#263)) ([9bcce88](9bcce88)), closes [#262](#262)
@karmarunnerbot
Copy link
Member

🎉 This PR is included in version 3.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot read property 'origin' of undefined (NativeScript)
3 participants