Improving assertion consistency, fluency and conventions in v5 #94
Replies: 2 comments 1 reply
-
I would keep the aliases because everyone has its own preferences (I personally only use ex: doc.md### equal(actual, expected, [description])
performs a deep equal check
(aliases: ``eq``, ``deepEqual``, etc)
Regarding
I like this idea (naming is hard) |
Beta Was this translation helpful? Give feedback.
-
Hey, I do not manage to mention you in the following discussion, can you please have a look and let me know your first impressions. thanks. LR |
Beta Was this translation helpful? Give feedback.
-
Since v5 will be a major release, how about nixing some of the assertion aliases?
It's an opinion, of course - but I don't find the aliases do anything to help with comprehension, they just muddy things and raise questions... "what's the difference between
equal
,deepEqual
andsame
?" - in some frameworks, these mean different things. In my opinion, it would be better not to waste time deciphering ambiguous terminology, debating which ones to use, refactoring in codebases with multiple contributors, and so on. (same
is particularly confusing here, because, in some frameworks, that word is used for identity comparison, which is whatis
does in zora.)I also would love it if the assertion object could have a better name (solely by convention, of course) than
t
- something that made sense for all the standard assertion names. Personally, I useis
, which works for almost all assertions:It doesn't work well for all cases - I wish we could have used
test
, but, obviously not.check
orassert
is clumsy to type, which is probably why you went witht
in the first place.If we can't think of a meaningful, keyboard friendly name for this, maybe consider getting rid of the name altogether, and make it conventional to destructure instead, since that's an option now?
Of course, the assertions are a little less close at hand if the convention is to unpack them declaratively in this way.
I currently use a mix of these styles in my own tests - I'll unpack
throws
for example, and leave the rest asis
:This reads more like "language", but makes it less obvious where the assertions are - you don't immediately spot things like
throws
when you're probably skimming foris
.I'm not proposing a solution here - I'm inviting to think about an API and conventions that read more fluently in v5. 😏
Beta Was this translation helpful? Give feedback.
All reactions