Proposal to use the `sinon-chai` dependency

In the CHT codebase tests we frequently use sinon and we frequently use chai. What are people’s thoughts of also using sinon-chai? :smiley:

TLDR is that it extends chai to include assertions that you would normally make about sinon stubs.

So, now we might have something like:

expect(myStubbedFn.calledOnce).to.be.true;

This extension lets us do:

expect(myStubbedFn).to.have.been.calledOnce;
1 Like

i love it! is it maintained?

1 Like

TLDR is yes, I consider it to be maintained!

To add a bit more details, the package is 14 years old and seems more-or-less “complete” in terms of containing the functionality to map the existing sinon features into chai. So, not a lot of churn in the codebase (and the last release was a year ago). However, the last release was to add support for Chai 5 (the latest major release of Chai). So, it is at least current in that regard (and there is some hope it will be updated for future versions as well…).

Also, GitHub lists 191,000 packages as having this as a dependency so we are def not the only ones that would be using it… :sweat_smile:

hey @jkuester do they differ internally or it’s just nice way to write?

I think it is just syntactic sugar. :+1: The actual asserting being made remains the same, but I think sinon-chai allows for more semantic test code.

1 Like