Skip to content

docs: update Vitest instructions for jest-dom #1229

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

Closed
wants to merge 2 commits into from

Conversation

unikitty37
Copy link

Add instructions on how to configure Vitest to import @testing-library/jest-dom automatically, to match the Vite instructions at 6.2.

Add instructions on how to configure Vitest to import @testing-library/jest-dom automatically, to match the Vite instructions at 6.2.
@netlify
Copy link

netlify bot commented Mar 8, 2023

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 0c7931c
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/6409ddefdc85bc0008a0737f
😎 Deploy Preview https://deploy-preview-1229--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -66,6 +66,26 @@ with any testing framework and runner you're comfortable with.
```js
import '@testing-library/jest-dom';
```

To have Vitest import this automatically in _every_ test file, add the import statement to a new file, then add the file to the `setupFiles` array in the `vitest.config.ts` (in this case, the file is `vitest.include.jsdom.ts` in the project root)
Copy link
Member

@timdeschryver timdeschryver Mar 8, 2023

Choose a reason for hiding this comment

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

Thanks for this addition to the docs.
What do you think of adding this under a 5.3 bullet point?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's a good idea.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Why would you use a library specifically for Jest in Vitest? We already have an assertion library specifically for Vitest called vitest-dom. Could we clarify first if the folks at @testing-library/jest-dom want to support Vitest in addition to Jest?

@unikitty37
Copy link
Author

Why would you use a library specifically for Jest in Vitest? We already have an assertion library specifically for Vitest called vitest-dom. Could we clarify first if the folks at @testing-library/jest-dom want to support Vitest in addition to Jest?

I was just updating the current documentation, which uses jest-dom. I didn't even know about vitest-dom — but it doesn't seem to be compatible with the current vitest version:

╰─▷ npm i -D vitest-dom
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vitest
npm ERR!   dev vitest@"~0.25.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vitest@"^0.16.0" from [email protected]
npm ERR! node_modules/vitest-dom
npm ERR!   dev vitest-dom@"*" from the root project

@unikitty37
Copy link
Author

Since vitest-dom doesn't work with current vitest, and my comment pointing this out doesn't seem to have resulted in any response, I'm going to assume this contribution is unwanted at this point.

@unikitty37 unikitty37 closed this Apr 6, 2023
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.

3 participants