Proposal: .either.some.or.someElse
See original GitHub issueWould be nice to have .either
as a delimiter and .or
as finalizer of assertion chain.
Something like:
.to.be.equal('five').either.an('object').or.a('number')
There could be just one .or
. And as many as need .eithers
.
What you say?
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
PROPOSE | English meaning - Cambridge Dictionary
propose definition: 1. to offer or suggest a possible plan or action for other people to consider: 2. to suggest…. Learn more.
Read more >Either, Or and Neither, Nor: How to Use Them (With Examples)
Neither & nor are used in a negative sense to show that the person will not choose either option, for example, “I will...
Read more >How to Use Either, Neither, Or, and Nor Correctly
Just remember this quick trick: “Either” and “or” both begin with vowels, so they go together. And “neither” and “nor” both start with...
Read more >Subject-Verb Agreement - Grammar - Academic Guides
Collective nouns are words that imply more than one person but are considered singular and take a singular verb. Some examples are "group,"...
Read more >Either and neither - English Grammar - Gymglish
Either...Or ('one or another') is used in affirmative sentences to offer a choice between two possibilities, or to express a cause-effect relationship: I...
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
I would strongly urge you to reconsider how you’re structuring your tests rather than write a plugin for adding
or
functionality.If you find yourself needing
or
in your tests, it suggests one of two things:or
, I’d advise refactoring your tests, using test doubles as needed, in order to make your tests deterministic. The goal is for your tests to produce the exact same result each time they’re run. And then, as @keithamus exemplified in his first reply, a separate test should be written with different inputs (or different test doubles) in order to validate that the expected result is produced under each set of circumstances. Here’s a pretty good resource on this topic: http://martinfowler.com/articles/nonDeterminism.htmlor
.That’s pretty much how chai works - and I think it is indeed part of chai’s responsibility to guide you into writing “correct” tests (or at least, avert you from writing incorrect ones). We also have limited resource and have to carefully curate what comes into core - this means we have a desire to keep core focussed on, well, core stuff. An
either
assertion breaks away from Chai’s core model, which stops us being focussed.I think this is exactly the mindset I’d like for us to be after. In an ideal world - I’d like for chai users to create plugins for all the assertions they want, and chai-core periodically vacuums up the ones 90% of users install. Plugins become useful to either A) pick up domain or framework specifics (e.g. chai-react) or B) break out of chai’s core model, for better or worse (chai-as-promised, chai-things, and the theoretical either-or you talk about).