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

@iammerrick iammerrick commented Mar 12, 2013

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 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

@iammerrick iammerrick commented Mar 12, 2013

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 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

@iammerrick iammerrick commented Mar 12, 2013

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

@curvedmark curvedmark commented May 8, 2013

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

@metaskills metaskills commented May 8, 2013

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 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 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 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 Jun 5, 2013
@iammerrick
Copy link
Contributor Author

@iammerrick iammerrick commented Jun 5, 2013

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

@tj
Copy link
Contributor

@tj 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

@metaskills metaskills commented Jun 5, 2013

Would love anything formalized. Either way, thanks everyone!

@metaskills
Copy link

@metaskills metaskills commented Jun 14, 2013

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

@dominicbarnes dominicbarnes commented Jun 19, 2013

+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

@johnaschroeder johnaschroeder commented Jun 20, 2013

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

@alexgorbatchev
Copy link

@alexgorbatchev alexgorbatchev commented Jun 25, 2013

👍

1 similar comment
@mallim
Copy link

@mallim mallim commented Jun 25, 2013

👍

@metaskills
Copy link

@metaskills metaskills commented Jun 25, 2013

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 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants