Cannot do `deep.nested` on an array, have to wrap it with an object
See original GitHub issueThis was a stackoverflow question - https://stackoverflow.com/q/53906051/1828637
He has a const payload = [{ id: 0 },{ id: 1 }]
and wants to do the following:
expect(payload).to.nested.include({
'[0].id': 0,
'[1].id': 1
});
But it does not work. He has to wrap it to get this to work:
const wrappedPayload = { a: payload };
expect(wrappedPayload).to.nested.include({
'a[0].id': 0,
'a[1].id': 1
});
I think this is a bug.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Mongoose - Cannot Update update deeply nested Objects
So you see its: Category -> products[] -> items[] I want to update the Objects in items array in the database and set...
Read more >Using ES6 To Destructure Deeply Nested Objects in ... - ITNEXT
Today, I will show you how to use ES6 to destructure nested objects, my friends, AND what's more, prevent the dreaded undefined error...
Read more >How to Deep Copy Objects and Arrays in JavaScript
The usual methods of copying an object or array only make a shallow copy, so deeply-nested references are a problem. You need a...
Read more >Accessing Nested Objects in JavaScript - DEV Community
Let's take this nested object as an example. const name = user.personalInfo.name; const userCity = user.
Read more >Safely Accessing Deeply Nested Values In JavaScript - Medium
Imagine we have a props objects, which might look something like the ... we want to access any deeply nested data we have...
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
In terms of current functionality, I don’t think there’s a silver bullet. Some options:
In terms of possible changes to functionality to support this:
.include
assertion to support.nested
with array targets.members
assertion to support.nested
Thanks very very much for sharing this info @meeber !