Skip to content
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

Port some matchers from jest-extended #2148

Closed
4 tasks done
silverwind opened this issue Oct 14, 2022 · 3 comments
Closed
4 tasks done

Port some matchers from jest-extended #2148

silverwind opened this issue Oct 14, 2022 · 3 comments

Comments

@silverwind
Copy link
Contributor

silverwind commented Oct 14, 2022

Clear and concise description of the problem

jest-extended brings many useful additional matchers, and while it's already possible to use it to extend vitest's expect, I'm wondering if there is any willingness to include a few more basic matchers from it into vitest itself because jest-extended is rather heavyweight.

I'm primarily looking at very simple matchers like .toStartWith(prefix), .toInclude(substring) or the type matchers like .toBeNumber().

Suggested solution

Port over a few of the generally useful matchers from jest-extended.

Validations

@sheremet-va
Copy link
Member

What are "generally useful" matchers, and why should they be in a core? If community wants to have a light weight jest-extended package, let them create one. We might mention it in a docs.

@silverwind
Copy link
Contributor Author

silverwind commented Oct 14, 2022

There are of course no hard rules on which matchers are generally useful, but for example

expect('string').toStartWith('string')

feels more "natural" because it's like String.prototype.startsWith. Compare to the regexp alternative vitest offers:

expect('string').toMatch(/^string/)

@silverwind
Copy link
Contributor Author

silverwind commented Oct 24, 2022

Actually, jest-extended is already reasonably lightweight and with jest-community/jest-extended#520, it should now also not pull in jest any more via peerDependencies like it previously did.

So I'm personally happy with keeping it as a dependency with vitest.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants