Replace property matchers with functions?

51 views
Skip to first unread message

Aaron Jensen

unread,
Mar 31, 2016, 3:06:34 PM3/31/16
to Chai.js
Hi there,

I like chai.js a lot, but I find that the property matchers have been problematic for me for two related reasons. One is that if you accidentally misspell a property matcher, the test will always pass. 

Example:

expect(bar).to.not.exsit

Will always pass because I have misspelled exist. 

Compare this to 

expect(bar).to.not.exsit()

which, if exist was a function matcher, would fail because that function is undefined.

The other reason is that it forces us to disable the no-unused-expressions eslint rule in order to use these property matchers.

So, is it possible to wholesale replace property matchers with functions matchers, and/or would Chai.js consider getting rid of the notion of property matchers entirely (big ask, I know, but unless I'm missing something, I believe them to be fundamentally flawed).

Thanks!

Aaron

Aaron Jensen

unread,
Mar 31, 2016, 3:11:36 PM3/31/16
to Chai.js
Reply all
Reply to author
Forward
0 new messages