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
Overall this technique is very useful for Chai. It helps their API read clearly, which could help a test suite function as documentation. However there could also be confusion when accessing what you think is a property, which could have unintended consequences. This pattern should be used with great care.