fix(expect): fix sinon-chai style API#9943
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| | `spy.returned` | `returned` | Spy returned successfully | | ||
| | `spy.returnedWith(value)` | `returnedWith(value)` | Spy returned specific value | |
There was a problem hiding this comment.
It looks like this was oversight or hallucination. Probably no way back to remove returnedWith, so now returnedWith and returned are essentially same.
| delegateTo: keyof Assertion, | ||
| ) { | ||
| utils.addChainableMethod( | ||
| utils.addMethod( |
There was a problem hiding this comment.
Chai's addChainableMethod uses Object.defineProperty({ get }) and addMethod uses simple assignment. Thus addMethod allows later addMethod to take over, but addChainableMethod breaks.
Not sure what was the purpose but ours aren't chainable anyways, so just switched to addMethod.
| // https://github.com/chaijs/sinon-chai | ||
| defProperty('called', 'toHaveBeenCalled') | ||
| defProperty('calledOnce', 'toHaveBeenCalledOnce') | ||
| defProperty('returned', 'toHaveReturned') |
There was a problem hiding this comment.
defProperty uses defineProperty(get), so later call of addMethod('returned') by sinon-chai breaks.
| // TODO: implement | ||
| // defMethod('thrown', 'toHaveThrown') |
There was a problem hiding this comment.
Not sure if we'd implement but just noted that they aren't fully ported yet.
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.