you need a describe in it to mark it as a test. mocha doesn't simply 
'require' your test files 

Am Dienstag, 25. Dezember 2012 09:29:20 UTC+1 schrieb Artur Vinogradov:
>
> Thank you, Martin. I solved my problems, but there's another question: 
> everything seems to work, test are running, but when i try to implement 
> http.get logic - it doesn't work. the code
>
> var http = require('http');
>
> http.get("http://www.google.com/index.html";, function(res) {
>  console.log("Got response: " + res.statusCode);
> }).on('error', function(e) {
>  console.log("Got error: " + e.message);
> });
>
> when I run "mocha" in console just writes "0 tests complete (0 ms)", 
> without logging anything.
>
> понедельник, 24 декабря 2012 г., 18:32:53 UTC+2 пользователь Martin Cooper 
> написал:
>>
>>
>>
>> On Mon, Dec 24, 2012 at 12:18 AM, Artur Vinogradov 
>> <[email protected]>wrote:
>>
>>> I installed mocha with -g parameter, though it's not been working for me 
>>> with other modules: I always had to link them, so that i can require them.
>>>
>>
>> It looks like you're not starting mocha properly. You shouldn't have that 
>> require of 'mocha' in there, and you need to be starting this using 'mocha' 
>> on the command line.
>>
>> The thing with mocha is that it doesn't just require your test module. It 
>> loads it into a special context, which is where global functions like 
>> 'describe' come from. In your case, 'describe' is not defined almost 
>> certainly because mocha was not started properly.
>>
>> --
>> Martin Cooper
>>  
>>
>> This is my code:
>>>
>>> var Mocha = require('mocha');
>>>
>>> var assert = require("assert")
>>> describe('Array', function(){
>>>   describe('#indexOf()', function(){
>>>     it('should return -1 when the value is not present', function(){
>>>       assert.equal(-1, [1,2,3].indexOf(5));
>>>       assert.equal(-1, [1,2,3].indexOf(0));
>>>     })
>>>   })
>>> })
>>>
>>> ReferenceError: describe is not defined
>>>     at Object.<anonymous> (/home/user/mocha/prog.js:3:1)
>>>     at Module._compile (module.js:449:26)
>>>     at Object.Module._extensions..js (module.js:467:10)
>>>     at Module.load (module.js:356:32)
>>>     at Function.Module._load (module.js:312:12)
>>>     at Module.runMain (module.js:492:10)
>>>     at process.startup.processNextTick.process._tickCallback 
>>> (node.js:244:9)
>>>
>>>  -- 
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines: 
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to