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

Cannot Run on CLI (process variable undefined errors) #58

Closed
dominicbarnes opened this issue Apr 29, 2013 · 12 comments
Closed

Cannot Run on CLI (process variable undefined errors) #58

dominicbarnes opened this issue Apr 29, 2013 · 12 comments

Comments

@dominicbarnes
Copy link
Contributor

@dominicbarnes dominicbarnes commented Apr 29, 2013

I can't seem to get mocha-phantomjs to run on the CLI. (below is my console output)

This occurs regardless of whether I use the NPM-installed version or the official download of PhantomJS. I've also tried downgrading mocha-phantomjs to previous versions to try and resolve, to no avail.

In addition, I know it's not mocha itself because even if I remove all my scripts from the page itself, the first 3 ReferenceErrors still occur exactly the same.

fwiw, I'm using Component.js to build my JS/CSS for the page, so I'm using the correct mocha script. (as mentioned in #8) In addition, my tests work completely fine in a full browser.

./node_modules/.bin/mocha-phantomjs test/test.html
ReferenceError: Can't find variable: process

  mocha-phantomjs/core_extensions.js:21
  mocha-phantomjs/core_extensions.js:82
ReferenceError: Can't find variable: process

  phantomjs://webpage.evaluate():2
  phantomjs://webpage.evaluate():8
  phantomjs://webpage.evaluate():8
ReferenceError: Can't find variable: process

  phantomjs://webpage.evaluate():3
  phantomjs://webpage.evaluate():17
  phantomjs://webpage.evaluate():17
%s%s  
%s%s    $.nh.durationspinner
%s%s      #stepUp()
TypeError: 'undefined' is not a function (evaluating 'process.stdout.write('\u001b[2K')')

  :1771
  :1779
  :3534
  :521
  :4250
  :4267
  :4300
  :4043
  :4303 in next
  :4307
  :5279 in timeslice
@dominicbarnes
Copy link
Contributor Author

@dominicbarnes dominicbarnes commented Apr 30, 2013

Aha! I figured it out. This commit (mochajs/mocha@dac0b29) removed the implied process global variable. Since I'm using Component.js, which wraps all modules in functions for require it blocked process from being added globally, which mocha-phantomjs was counting on.

There has to a better solution on the mocha-phantomjs side than relying on global state, any thoughts? This is especially relevant as I know that TJ intends to rewrite mocha as a component. (mochajs/mocha#573)

@vvo
Copy link

@vvo vvo commented May 1, 2013

Hi,

Had the same problem, not using component

You have to use mochajs/mocha@3d327c8 for mocha to work.

@dominicbarnes
Copy link
Contributor Author

@dominicbarnes dominicbarnes commented May 1, 2013

Yeah, I've dropped down to using version 1.9.0 for the time-being.

@ivanvotti
Copy link

@ivanvotti ivanvotti commented Jun 4, 2013

I had the same issue with process. Thank you, vvo, your suggestion works for me. It should be mentioned in documentation that mocha-phantomjs is not compatible with new mocha versions. The version that works for me is https://github.com/visionmedia/mocha/blob/3d327c87d2abfe94aa613d50b69b50f19361c190/mocha.js

@metaskills
Copy link
Collaborator

@metaskills metaskills commented Jun 4, 2013

It is documented, in a few places. First on the README.md here and then in the package.json here which should help you resolve these issues. If there is any other place I am missing, please let me know.

@metaskills metaskills closed this Jun 4, 2013
@mourner
Copy link

@mourner mourner commented Jun 5, 2013

It's not documented anywhere that mocha-phantomjs doesn't work with the latest Mocha (1.10), so I think this should be reopened and kept open until it works.

@ivanvotti
Copy link

@ivanvotti ivanvotti commented Jun 5, 2013

In README I can see "Tested with Mocha 1.8, Chai 1.5, and PhantomJS 1.9. The latest of these versions is recommended!" It looks not clear. It could save me time if in README there's something like:

Note: At the moment mocha-phantomjs only works with Mocha 1.8.x. It's not compatible with the latest version of Mocha. If you got "ReferenceError: Can't find variable: process" error" check the version you use.

@ikokostya
Copy link

@ikokostya ikokostya commented Jun 20, 2013

@metaskills Have you plans to support mocha >1.9?

@dominicbarnes
Copy link
Contributor Author

@dominicbarnes dominicbarnes commented Jun 20, 2013

@ikokostya The plans are there, he's just blocked because of Mocha itself at this point. (mochajs/mocha#770)

@aj0strow
Copy link

@aj0strow aj0strow commented Oct 6, 2013

any news on this? searched for a while after it broke on me this evening

@metaskills
Copy link
Collaborator

@metaskills metaskills commented Oct 6, 2013

This issue is closed because it is not longer an issue in mocha.js. The current versions from the readme are, Mocha 1.12.x, Chai 1.7.x, and PhantomJS 1.9.1.

@aj0strow
Copy link

@aj0strow aj0strow commented Oct 6, 2013

ah cool! I must have messed something up then

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