tj / should.js

BDD style assertions for node.js -- test framework agnostic
MIT License
2.75k stars 194 forks source link

.exist() for syntactic consistency #216

Closed jtmarmon closed 9 years ago

jtmarmon commented 9 years ago

should.js encourages english-like assertions so that they're very easy to read.

i.e.

response.should.have.header('content-length')

obj.should.have.keys('foo', 'baz');

And so on. However, to assert that a variable "exists" (which is often more clear or practical than asserting ....should.not.equal(undefined)) you must break the english-like pattern by writing should.exist(obj); There should be a way to write it like so: obj.should.exist()

jtmarmon commented 9 years ago

A friend of mine has pointed out that undeclaredVariable.should.exist() wouldn't exactly work ;) forgive me

btd commented 9 years ago

That is usually should.exist(abc) or should(abc).be.ok