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?
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
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