mocha - Test Cases fails if any of them fails -


i trying mocha test case check rest api, issue if have 3 test cases , first 1 fails rest not executing. stops @ first only.

here following code:

describe('suite 1',function(){   it('tc1',function(done){      // test case failure        should([1]).equal([]);        done();   })    it('tc2',function(done){      // test case success        should([]).equal([]);        done();   }) 

})

in above code not able report 2 test cases. 1 passed. 1 fail.

it fails in middle, in here fails on first test case only.

both tests failing because both should fail.

the both tests fail because using equal checks object identity. is, uses === check equality. now, open interactive node session , try this:

[] === [] 

you'll false. that's because each new empty array new javascript object , === true if 2 arrays same object.

note result expect in first test not reason (probably) think. test fails same reason i've explained. fact 1 array contains element other empty not taken account should.

you should use eql test whether arrays have same members.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -