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.

.lengthOf should work for sets and maps

See original GitHub issue

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

github_iconTop GitHub Comments

1reaction
keithamuscommented, Jun 9, 2018

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.

1reaction
meebercommented, Jan 7, 2018

Agreed. May also be worth adding .size as an alias to .lengthOf.

Read more comments on GitHub >

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

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