chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.14k stars 698 forks source link

Strange failing expectation -> AssertionError: expected [ 1, 2, 3 ] to be an array #960

Closed pietschy closed 7 years ago

pietschy commented 7 years ago

Hi there, I'm using 3.5.0 and am getting a very strange error.

I was trying to use the members assertion but was getting the error AssertionError: expected [ 1, 2, 3 ] to be an array. I tracked this down to line https://github.com/chaijs/chai/blob/3.5.0/lib/chai/core/assertions.js#L1556

When trying expect([1,2,3]).to.be.an('array') and found that _.type(obj) is returning "Array" at https://github.com/chaijs/chai/blob/3.5.0/lib/chai/core/assertions.js#L170

Very strangely, if I change test to expect([1,2,3]).to.be.an('Array') the type argument at line https://github.com/chaijs/chai/blob/3.5.0/lib/chai/core/assertions.js#L163 is still array and the test still fails.

Something very strange is going on and I'm completely baffled. Any ideas?

Other tool chain info: JSPM 0.17.x, Typescript 2.2

meeber commented 7 years ago

@pietschy Sounds like something in your tool chain is pulling in a newer version of the type-detect package than is supported by Chai v3.5. The problem isn't reproduced using an otherwise empty project with Chai v3.5 installed. I bet using chai@canary off npm will solve that problem. Otherwise gotta hunt down the type-detect conflict.

pietschy commented 7 years ago

Hi @meeber, that was it.

I'd used jspm install npm:chai --dev and for some reason it wasn't finding type-detect at runtime so I'd installed it manually to get it going.

Sweet relief. Thanks!