alexjeffburke / chai-better-shallow-deep-equal

MIT License
3 stars 0 forks source link

support for "exhaustively" #3

Open joeldodge79 opened 3 years ago

joeldodge79 commented 3 years ago

great plugin, thank you!

any plans for supporting 'to exhaustively satisfy'? maybe a shallowDeepEqualStrict assertion? If you don't have cycles to add it but are supportive of the idea I'd be happy to add it. Right now I'm hacking around it by running the assertion both ways (expected vs actual and actual vs expected).

alexjeffburke commented 3 years ago

Hi Joel, thanks very much, glad to hear it's working for you :) Hmm yeah actually this is something I've thought about before, especially given Unexpected has the support already in it. If there's been any sticking point, it's that I've never arrived at a good conclusion of how to expose the functionality so it fits with how chai does things.

Using a variant of the assertion name isn't a bad option, although the precedent around ...Strict from node assert is that it changes the kind of equality that is performed. Other thoughts included defining exhaustively as a property that can be chained through, so you'd end up with expect(<thing>).to.exhaustively.shallowDeepEqual(). That would read well, but due to chai's design has some nasty effects: exhaustively can suddenly be used inline with any assertion, but worse is that if you forget the assertion (i.e. expect(<thing>).to.exhaustively). That's true of the other built-in properties too :/ Along similar lines was intepreting the all flag as requesting exhaustively mode.

Does any of those alternatives stand out as better than the others?

alexjeffburke commented 3 years ago

@joeldodge79 would be good to get your input if this is something you're still keen on 🙂

joeldodge79 commented 3 years ago

sorry, missed the first notification.

I'll confess I'm not deeply steeped in the js/node/chai conventions but what about expect(<thing>).to.shallowDeepEqualExhaustively() to avoid confusion with node's assertStrict but to also avoid the potential chaining pitfalls/quagmire?

It is something I'd like to have eventually but am not dying to have. Also thought it might be a nice small little back-burner contribution I could work on when I have a minute. But that might be a little while so if you'd like to see it happen before I have time then go for it :-)