question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.deep.members always throws a TypeError

See original GitHub issue

hello,

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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
meebercommented, Nov 27, 2017

@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 a package-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.

1reaction
keithamuscommented, Nov 29, 2017

Hilariously this is the issue we tried to solve with the patch to type-detect. Back to the drawing board I guess.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found