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
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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With