.lengthOf should work for sets and maps
See original GitHub issuesets and maps use a different property .size
for their length but in the context of chai it should work the same way.
expect(new Set([1])).to.have.lengthOf(1);
// currently UncaughtException AssertionError: expected {} to have property 'length'
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Why do JavaScript Sets/Maps use `size` instead of `length`?
My guess is that sets and maps are not really considered one-dimensional vectors (having a "length") of items, like arrays are. Would you ......
Read more >JavaScript maps vs. sets: Choosing your data structure
JavaScript's Map and Set data structures, play a crucial role in working with the data we collect. Learn all you need to know...
Read more >Map and Set - The Modern JavaScript Tutorial
So we should use map methods: set , get and so on. Map can also use objects as keys.
Read more >19. Maps and Sets - Exploring JS
19.6.1. Why do Maps and Sets have the property size and not length ? 19.6.2. Why can't I configure how Maps and Sets...
Read more >JavaScript maps and sets part 1 - Mitya.uk
In this guide we'll be looking at JavaScript maps and sets. First up, maps, which are a sort of super object. They work...
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
hey @rijnhard thanks for this issue!
We’re adding this in chai 5, we’ve added this to our Roadmap https://github.com/chaijs/chai/projects/2! We’ll be releasing chai 5 soon, but for now I’ll close this issue because it is tracked on our roadmap.
Agreed. May also be worth adding
.size
as an alias to.lengthOf
.