New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add satisfy alias #1172
feat: add satisfy alias #1172
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Can you add a simple test for it? Thanks |
@antfu done ✅ |
To me it seems like + import { vi } from 'vitest'
describe.only('toSatisfy()',() => {
const isOdd = (value: number) => value % 2 !== 0
it('pass with 0',() => {
expect(1).toSatisfy(isOdd)
})
it('pass with negotiation',() => {
expect(2).not.toSatisfy(isOdd)
})
+
+ it('calls the function',() => {
+ const isOddMock = vi.fn(isOdd)
+ expect(isOddMock).not.toBeCalled()
+ expect(1).toSatisfy(isOddMock)
+ expect(isOddMock).toBeCalled()
+ })
+
+ it('fails when not satisfied',() => {
+ const shouldFailFn = () => expect(2).toSatisfy(isOdd)
+ expect(shouldFailFn).toThrow()
+ })
}) |
Here's a reproduction link Do you want me to open an issue? |
You could also directly open a PR 🙂 |
@fardolieri : I created a PR with a fix: #1350 |
Awesome, thanks for stepping in! |
In Faker we want to use
expect(...).to*
assertions so we have consistent tests for everything.Examples: