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

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

Comments

Projects
None yet
7 participants
@dominicbarnes
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@dominicbarnes

dominicbarnes Apr 30, 2013

Contributor

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)

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@vvo

vvo May 1, 2013

Hi,

Had the same problem, not using component

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

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

This comment has been minimized.

Show comment
Hide comment
@dominicbarnes

dominicbarnes May 1, 2013

Contributor

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

Contributor

dominicbarnes commented May 1, 2013

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

@ivanvotti

This comment has been minimized.

Show comment
Hide comment
@ivanvotti

ivanvotti 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

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

This comment has been minimized.

Show comment
Hide comment
@metaskills

metaskills Jun 4, 2013

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@mourner

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

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

This comment has been minimized.

Show comment
Hide comment
@ivanvotti

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

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

This comment has been minimized.

Show comment
Hide comment
@ikokostya

ikokostya Jun 20, 2013

@metaskills Have you plans to support mocha >1.9?

@metaskills Have you plans to support mocha >1.9?

@dominicbarnes

This comment has been minimized.

Show comment
Hide comment
@dominicbarnes

dominicbarnes Jun 20, 2013

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@aj0strow

aj0strow Oct 6, 2013

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

aj0strow commented Oct 6, 2013

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

@metaskills

This comment has been minimized.

Show comment
Hide comment
@metaskills

metaskills Oct 6, 2013

Collaborator

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.

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@aj0strow

aj0strow Oct 6, 2013

ah cool! I must have messed something up then

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