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

Mocha Breaks Libraries Using process for environment detection. #770

Closed
iammerrick opened this issue Mar 12, 2013 · 19 comments
Closed

Mocha Breaks Libraries Using process for environment detection. #770

iammerrick opened this issue Mar 12, 2013 · 19 comments

Comments

@iammerrick
Copy link
Contributor

Please see an example repository at https://github.com/iammerrick/mocha-rjs-fail.

The Problem

Mocha.js installs a global called process see here. A comment says it is only to allow mocha.js to run untouched, not to allow running node code in the browser, however this has some unfortunate side effects for some libraries that use process for environment detection.

r.js is one of those libraries that uses process for environment detection see here.

@tj
Copy link
Contributor

tj commented Mar 12, 2013

hmm yeah that sort of thing gets messy, we should be able to pretty easily avoid that if we do our own checking

@iammerrick
Copy link
Contributor Author

Does that mean the browser doesn't use these lines of code: https://github.com/visionmedia/mocha/blob/master/mocha.js#L5229-L5290

Also thanks for your quick response.

M

@tj
Copy link
Contributor

tj commented Mar 12, 2013

actually maybe what we can do is just wrap those in the anonymous closure there so that we're not leaking process, the rest would still be the same, that should be fine

@iammerrick
Copy link
Contributor Author

I think its in a closure, what we really need is a var statement on https://github.com/visionmedia/mocha/blob/master/mocha.js#L5237. Right?

@curvedmark
Copy link
Contributor

Just want to let you guys know that this change breaks mocha-phantomjs nathanboktae/mocha-phantomjs#58, which need to override some methods in process.

I guess one way to fix this is to expose process in the browser with Mocha.process, and mocha-phantomjs should use that instead.

Not sure what @visionmedia and @metaskills think about this.

@metaskills
Copy link

Agreed, something should happen. Even when PhantomJS 1.9.1 comes out with proper std{out,error} support, see my issue 50, we will see need to capture Mocha's process.stdout.write so we can push it back up the proper PhantomJS IO stream.

@tj
Copy link
Contributor

tj commented May 22, 2013

hmmm tricky.. if we get too cute there it's going to be one huge PITA to maintain, Mocha.process is pretty ugly but I guess it would do

@mourner
Copy link

mourner commented Jun 5, 2013

+1, had to revert to Mocha 1.9.0 to use it with PhantomJS and grunt-mocha-phantomjs grunt plugin...

@tj
Copy link
Contributor

tj commented Jun 5, 2013

I'll close this one since it has been merged, but we'll need to tweak for the phantom stuff

@tj tj closed this as completed Jun 5, 2013
@iammerrick
Copy link
Contributor Author

The grunt-mocha-phantom was built on top of a hack. My vote is we expose using Mocha.process.

@tj
Copy link
Contributor

tj commented Jun 5, 2013

even having Mocha.process is pretty hacky too :( necessary I suppose, maybe we can formalize a nicer api for intercepting that data

@metaskills
Copy link

Would love anything formalized. Either way, thanks everyone!

@metaskills
Copy link

close this one... but we'll need to tweak for the phantom stuff

Is there a new issue that is tracking that?

@dominicbarnes
Copy link
Contributor

+1 for Mocha.process as well, I would really like to be able to upgrade to newer versions of mocha with mocha-phantomjs. :)

@johnaschroeder
Copy link

+1, would also like to be able to upgrade to newer versions of mocha with mocha-phantomjs.

@alexgorbatchev
Copy link

👍

1 similar comment
@mallim
Copy link

mallim commented Jun 25, 2013

👍

@metaskills
Copy link

Please, I do not want this to be an up vote thread.

@visionmedia Is there another issue that has opened up for this or is this something you are not working on? If so, can you give anyone feedback on what would be OK by you for someone to work on and create a new pull request.

@diwu1989
Copy link

diwu1989 commented Jul 1, 2013

I put in this pull request just now #916

It exposes the shim process that Mocha uses as Mocha.process.

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

No branches or pull requests

10 participants