I have encountered a weird error when trying to assert that a result should equal to an array, when using Chai.
Code Example
describe("compare array", function() {
it("should return an empty array", function() {
const result = getEmptyList(); // just a silly example
expect(result).to.equal([]);
});
});
Result
× compare array
PhantomJS 2.1.1 (Windows 8.0.0)
expected [ find: [Function] ] to equal [ find: [Function] ]
AssertionError@C:/Code/example/node_modules/chai/chai.js:9449:24
assert@C:/Code/example/node_modules/chai/chai.js:239:31
assertEqual@C:/Code/example/node_modules/chai/chai.js:1387:18
methodWrapper@C:/Code/example/node_modules/chai/chai.js:7824:30
test/unit/utils/example.js:5:32
When I instead expect the length of the result to equal zero, it works fine. Can anyone share some insights to why this is happening. Why is [ find: [Function] ]
all of a sudden expected, instead of []
as was desired?
I am using Karma as my test runner.