fix: proper vitest ts support (#515) #589
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What:
This PR extends Vitest's default
Assertion
interface to fix thetoBeInTheDocument
ts error when using Vitest (#515).Why:
I don't know (still cannot reproduce #515 on my own computer). But from this comment, adding
/// <reference types="@testing-library/jest-dom" />
in custom
vitest-setup.ts
file would fix this error in that situation. Therefore I think thetypes/vitest.d.ts
may need to be updated.And when I install this repo's dependencies by pnpm and running
tsc -p types/__tests__/vitest
, there would be similar errors of #515 (if using npm orimport '../../jest'
instead ofimport '../../vitest'
like that comment, there would be no error). This PR would fix this error even using pnpm.How:
https://vitest.dev/guide/extending-matchers.html
Checklist: