Mocha describe is not defined

I have a directory called MochaTests. Inside there I have the example test found on the mocha website "1.2.3 Mocha". At the command prompt (My OS is WIN7), I type in Mocha, and the result is 0 passing(2 m2). I installed just like the instructions say: npm install -g mocha from what I can tell it installs just fine

So, in c:\MochaTests> I type node then I type .load test1.js I get

ReferenceError: describe is not defined.

On the nodejs googlegroup there is a post dated 2012-12-24 that is titled "describe is not defined"… they claims this "solved my problems", but did not provide any details about what he did to clear up this error.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

tl;dr

You’ll want to run mocha instead of node:

Install Mocha (globally)

npm install mocha -g

Then, run mocha

mocha

OLD (the post has since been removed):

This post says to use mocha instead of node in your command which works for me:

http://comments.gmane.org/gmane.comp.lang.javascript.nodejs/58313

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply