For example, to verify a listener has been called looks like this:
Or testing that something is truthy:
1 2 3 4 5
expect('everthing').to.be.ok; expect(1).to.be.ok; expect(false).to.not.be.ok; expect(undefined).to.not.be.ok; expect(null).to.not.be.ok;
Looking into the source, we found that Chai was using the
If you’re unfamiliar with the
This pattern can be nice and make syntax slightly more natural to read, but it also carries some gotchas. Since a property is being referenced and not a function, it is important to check spelling and the existence of the property. For example, if you were to run:
There would be no failure. With that in mind, this pattern should be used with care in order to prevent unintended consequences.