fix(expect): fix sinon-chai style API (#9943) · vitest-dev/vitest@0f08dda
@@ -44,7 +44,7 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {
4444name: keyof Assertion,
4545delegateTo: keyof Assertion,
4646) {
47-utils.addChainableMethod(
47+utils.addMethod(
4848chai.Assertion.prototype,
4949name,
5050function (this: Chai.AssertionStatic & Assertion, ...args: any[]) {
@@ -56,13 +56,13 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {
5656}
5757return jestMethod.call(this, ...args)
5858},
59-() => {},
6059)
6160}
626162+// API to (somewhat) mirror sinon-chai
63+// https://github.com/chaijs/sinon-chai
6364defProperty('called', 'toHaveBeenCalled')
6465defProperty('calledOnce', 'toHaveBeenCalledOnce')
65-defProperty('returned', 'toHaveReturned')
6666defPropertyWithArgs('calledTwice', 'toHaveBeenCalledTimes', 2)
6767defPropertyWithArgs('calledThrice', 'toHaveBeenCalledTimes', 3)
6868@@ -71,10 +71,14 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {
7171defMethod('calledOnceWith', 'toHaveBeenCalledExactlyOnceWith')
7272defMethod('lastCalledWith', 'toHaveBeenLastCalledWith')
7373defMethod('nthCalledWith', 'toHaveBeenNthCalledWith')
74+defMethod('returned', 'toHaveReturned')
7475defMethod('returnedWith', 'toHaveReturnedWith')
7576defMethod('returnedTimes', 'toHaveReturnedTimes')
7677defMethod('lastReturnedWith', 'toHaveLastReturnedWith')
7778defMethod('nthReturnedWith', 'toHaveNthReturnedWith')
7879defMethod('calledBefore', 'toHaveBeenCalledBefore')
7980defMethod('calledAfter', 'toHaveBeenCalledAfter')
81+82+// TODO: implement
83+// defMethod('thrown', 'toHaveThrown')
8084}