Add check to see if we really are in node even if document exists#40
Add check to see if we really are in node even if document exists#40amadsen wants to merge 2 commits intotapjs:mainfrom
Conversation
|
@isaacs Please let me know if there is anything I can do to improve this pull request. Thanks! |
lib/utils.js
Outdated
There was a problem hiding this comment.
This will throw if process is not defined.
There was a problem hiding this comment.
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
documenthas been mocked in a node environment, but many other interfaces provided by a browser have not that causestap-mocha-reporterto 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.