Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Mocha equal tests?

I am testing an Express Node app with Mocha. I would like to have the following test (comparing two empty arrays):

assert.equal [], []

to pass. However, Mocha gives me the following error: AssertionError: [] == []

Which method should I use in order for comparison of two empty arrays to pass?

like image 479
AdamNYC Avatar asked Nov 29 '22 16:11

AdamNYC


1 Answers

If you're comparing objects ({} or []) you have to use assert.deepEqual() because if you do assert.equal([], []) you're just comparing the references: {} === {} (or [] === []) will be always false.

http://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message

like image 72
Gabriel Llamas Avatar answered Dec 01 '22 05:12

Gabriel Llamas