Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test is not showing passing when using should

i am first time testing i write a test case

var should = require("should")
describe('Array', function(){
  describe('#indexOf()', function(){
    it('should return -1 when the value is not present',function(){
      [1,2,3].indexOf(5).should.equal(-1);
      [1,2,3].indexOf(0).should.equal(-1);
    })
  })
})

its giving me 0 passing

 0 passing (1ms)

but why it should show 1 passing

like image 644
Nitin Avatar asked Oct 10 '13 15:10

Nitin


2 Answers

By default, if no parameters provided, mocha is looking in ./test directory.

If you saved the test above somewhere else (may be in current directory), you shall provide the path to this file as a parameter to mocha.

Assuming that test is saved in a file test.js, you shall execute it as following:

% mocha test.js
  ․
  1 passing (5ms)
like image 98
Andrei Karpushonak Avatar answered Nov 04 '22 23:11

Andrei Karpushonak


For those wondering, just make sure to also have an it(...) section in your test. Mocha needs this to recognize that there is something here needing to be tested.

like image 24
Chris Vasquez Avatar answered Nov 05 '22 00:11

Chris Vasquez