-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add check to see if we really are in node even if document exists #40
base: main
Are you sure you want to change the base?
Conversation
@isaacs Please let me know if there is anything I can do to improve this pull request. Thanks! |
lib/utils.js
Outdated
@@ -643,7 +643,7 @@ exports.getError = function(err) { | |||
|
|||
exports.stackTraceFilter = function() { | |||
var slash = '/' | |||
, is = typeof document === 'undefined' | |||
, is = (typeof document === 'undefined' || /(node|iojs)/.test(((process || {}).release || {}).name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw if process
is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I have updated the pull request to use a helper function (rather than nest a ternary).
A simpler alternative would be to test for process
the way the existing code tests for document
and reverse the ternary - the assumption being that a browser environment is much less likely to mock the process
object than a node environment is to mock document
.
Also, I'll see if I can come up with a useful way to test this in a browser environment. Can you describe (or point to an example of) what that might look like?
So, multiple additional thoughts:
versus
Just checking for
Removing |
This fixes an issue where
document
has been mocked in a node environment, but many other interfaces provided by a browser have not that causestap-mocha-reporter
to throw a RefferenceError instead of properly reporting an error documented in the TAP stream. It also adds a couple of tests and a few files to support those tests.