fix(expect): fix sinon-chai style API (#9943) · vitest-dev/vitest@0f08dda

@@ -44,7 +44,7 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {

4444

name: keyof Assertion,

4545

delegateTo: keyof Assertion,

4646

) {

47-

utils.addChainableMethod(

47+

utils.addMethod(

4848

chai.Assertion.prototype,

4949

name,

5050

function (this: Chai.AssertionStatic & Assertion, ...args: any[]) {

@@ -56,13 +56,13 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {

5656

}

5757

return jestMethod.call(this, ...args)

5858

},

59-

() => {},

6059

)

6160

}

626162+

// API to (somewhat) mirror sinon-chai

63+

// https://github.com/chaijs/sinon-chai

6364

defProperty('called', 'toHaveBeenCalled')

6465

defProperty('calledOnce', 'toHaveBeenCalledOnce')

65-

defProperty('returned', 'toHaveReturned')

6666

defPropertyWithArgs('calledTwice', 'toHaveBeenCalledTimes', 2)

6767

defPropertyWithArgs('calledThrice', 'toHaveBeenCalledTimes', 3)

6868

@@ -71,10 +71,14 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => {

7171

defMethod('calledOnceWith', 'toHaveBeenCalledExactlyOnceWith')

7272

defMethod('lastCalledWith', 'toHaveBeenLastCalledWith')

7373

defMethod('nthCalledWith', 'toHaveBeenNthCalledWith')

74+

defMethod('returned', 'toHaveReturned')

7475

defMethod('returnedWith', 'toHaveReturnedWith')

7576

defMethod('returnedTimes', 'toHaveReturnedTimes')

7677

defMethod('lastReturnedWith', 'toHaveLastReturnedWith')

7778

defMethod('nthReturnedWith', 'toHaveNthReturnedWith')

7879

defMethod('calledBefore', 'toHaveBeenCalledBefore')

7980

defMethod('calledAfter', 'toHaveBeenCalledAfter')

81+82+

// TODO: implement

83+

// defMethod('thrown', 'toHaveThrown')

8084

}