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

fix: proper vitest ts support (#515) #589

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nyaapass
Copy link

@nyaapass nyaapass commented Mar 11, 2024

What:

This PR extends Vitest's default Assertion interface to fix the toBeInTheDocument 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 the types/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 or import '../../jest' instead of import '../../vitest' like that comment, there would be no error). This PR would fix this error even using pnpm.

image

How:

https://vitest.dev/guide/extending-matchers.html

Checklist:

  • Documentation
  • Tests
  • Updated Type Definitions
  • Ready to be merged

@ecoms-ye
Copy link

Confirmed in my office computer (a pnpm monorepo with the With Vitest and With TypeScript setup):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants