.deep.members always throws a TypeError
See original GitHub issuehello,
i upgraded chai in a project from 3.5.0
to 4.1.2
and got a lot of errors from comparing arrays of objects with .deep.equal
. i checked the changelog and saw that checking equality has been changed a lot so i tried to rewrite those test with .members
. i tried
expect([{
type: 'whatever',
payload: {
message: 'blablabla'
}
}).to.have.deep.members([{
type: 'whatever',
payload: {
message: 'blablabla'
}
}])
but got a TypeError: Right-hand side of 'instanceof' is not an object
. i tried every combination of .members
, .deep
, .ordered
and maybe .include
with no luck. at the end i copied the example
expect([{a: 1}]).to.have.deep.members([{a: 1}]);
from the documentation but got the same TypeError. what am i missing?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Expect / Should - Chai Assertion Library
When the target is expected to throw an error, it's often best to assert that the error is of its expected type, and...
Read more >expect().to.be.ordered.members() throw an error "TypeError ...
Whenever I try to compare array (order matters) with the command expect(...).to.be.ordered.members(...) , Cypress always throw an error.
Read more >Deep Javascript check if undefined without TypeError
I would suggest to try and avoid deep nesting like you have. ... If Foo.bar or Foo.bar.baz are undefined, you will not get...
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
7. TypeError: 'undefined' is not a function. This error occurs when you try to invoke a method that doesn't exist in your script,...
Read more >Using ES6 To Destructure Deeply Nested Objects in ... - ITNEXT
It just flat out didn't exist. TypeError: Cannot read property 'params' of undefined . It's so annoying — especially when it causes React...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gex I think something else is going on. Your last example works fine for me; I copied and pasted it into a new project with nothing but Chai 4.1.2 and Mocha. The first example is missing a
]
to close the first array, but once that’s fixed, it works fine for me too. May be worth deleting node_modules and reinstalling dependencies. I also wonder if there could be apackage-lock.json
issue. Since your stand-alone examples work, it’s hard to speculate what the problem is that’s causing errors in your project.Hilariously this is the issue we tried to solve with the patch to type-detect. Back to the drawing board I guess.