Add assertions for ES6 Maps and Sets
See original GitHub issue@tiemevanveen you should raise a new issue - we can discuss the design of this and work towards adding it as a feature 😄
It would be cool if there would be assertions for ES6 Maps (and Sets).
For example something like:
expect(myMap).to.have.key('some_key');
Currently one could use:
expect(myMap.has('some_key'), 'map should have some_key').to.be.true;
But that doesn’t work great…
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Testing Maps/Sets with QUnit (or other Unit Testing Tool)
The intention is to assert that the elements of the Sets/Maps are equal. Both the both assertions should fail. Is there an equivalent...
Read more >19. Maps and Sets - Exploring JS
19.2.4 Iterating over Maps # ... Let's set up a Map to demonstrate how one can iterate over it. const map = new...
Read more >JavaScript maps vs. sets: Choosing your data structure
Every Set object will originally have a has() method that can be called to assert whether or not an element with a specified...
Read more >Collecting and iterating, the ES6 way - Chrome Developers
Set s offer a way of keeping track of a collection of items in which each item can appear at most once. Map...
Read more >How JavaScript works: understanding Maps and their use ...
Maps were introduced in JavaScript in ES6 . ... In Maps, you can add a new set of entries (key-value pair) at any...
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
@lucasfcosta
I would expect this to fail. Keys in maps and values in sets are by reference and checked that way using
has
@bnord01 thanks for the explanation, I didn’t know that. Makes total sense to me. 😃
EDIT Note: This is done that way on #633