Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

.not is an antipattern #135

Open
btd opened this issue Jan 27, 2017 · 3 comments
Open

.not is an antipattern #135

btd opened this issue Jan 27, 2017 · 3 comments

Comments

@btd
Copy link
Member

btd commented Jan 27, 2017

.not modifier, while it looks very usefull from breaf view is clearly antipattern. I personally avoiding use it.
It produce additional class of possible problems like:

(10).should.not.be.a.Number()

There we see assertion object 10 to not be a Number, but assume you have more complex object you get from API response. So each time .not used need clearly rereview its usage.

Single usefull case for .not it is usage with .eql and .equal based assertions. When we know the actual object should not be equal to given in some way.

So probably it is worth to deprecate .not for everything by not .eql and .equal

@btd btd added the discussion label Jan 27, 2017
@Qix-
Copy link
Contributor

Qix- commented May 15, 2017

I'd be more interested in use-cases that claim to require the use of .not. Now that you mention it, I personally can't think of any uses of .not that wouldn't benefit from more specific assertions.

@tonylukasavage
Copy link
Contributor

ditto above, been using should.js for years and have almost never used .not

@ncthbrt
Copy link

ncthbrt commented Sep 20, 2017

Testing removal is an example of where .not is very useful:
a.remove('b')
a now shouldn't contain b

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants