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

Closed
wants to merge 2 commits into 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):

@Dalcvi
Copy link

Dalcvi commented Aug 21, 2024

What is the reason that this change is not being merged in? Vitest removed @vitest/expect interface, so when @testing-library/jest-dom/vitest is trying to extend @vitest/expect interface, it just does nothing. By the way I see it, this change actually corrects the way you are expected to extend the interface since 0.x.x version, so what is the hold up here?

Comment on lines +4 to +5
type Assertion,
type AsymmetricMatchersContaining,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are unused.

You actually type out the name but don't use it in the line 14 and 19.

@Dalcvi
Copy link

Dalcvi commented Aug 21, 2024

What is the reason that this change is not being merged in? Vitest removed @vitest/expect interface, so when @testing-library/jest-dom/vitest is trying to extend @vitest/expect interface, it just does nothing. By the way I see it, this change actually corrects the way you are expected to extend the interface since 0.x.x version, so what is the hold up here?

Alright, other PR was changed with these changes 06d19ba waiting for release I guess

@gnapse
Copy link
Member

gnapse commented Aug 29, 2024

I guess we can close this as superseded by #612

@gnapse gnapse closed this Aug 29, 2024
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.

4 participants