What are Mocha equal tests?

前端 未结 2 826
心在旅途
心在旅途 2021-01-13 13:40

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

assert.equal [], []

to p

2条回答
  •  囚心锁ツ
    2021-01-13 14:33

    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

提交回复
热议问题