-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
expect(promise).rejects.toThrow()
broken by @testing-library/jest-dom/vitest
with server.deps.inline: true
#5285
Comments
It looks like I think the recommended usage is to only put only packages which are not compatible plain NodeJS ESM and it's mostly used as a workaround https://vitest.dev/config/#server-deps-inline Related to |
expect(promise).rejects.toThrow()
broken by @testing-library/jest-dom/vitest
with server.deps.inline: true
Confirmed that modifying server.deps.inline to an array of package names worked. |
I wouldnt call this a repro, but I hit this as well: https://github.com/dcramer/peated/pull/153/files One thing I want to note is I'm not using the referenced library, as my tests are not DOM coupled:
|
@dcramer Do you use |
I thought this is Thanks for reporting. It's a huge repro, so if you can minimize it, then that would be great, but at least we have things to look at. |
I had the same error, on my project it was somehow related to vitest-fail-on-console. I fixed the issue by upgrading it from 0.5.1 to 0.6.3. |
Looks like the issue happens when you have different Vitest versions installed: chaijs/check-error#51 |
Describe the bug
I'm using vitest in global mode. If I use @testing-library/jest-dom by importing it in setupTests.ts like so:
import "@testing-library/jest-dom/vitest";
Most test matchers work as expected, including those added by jest-dom. However, the matcher for rejected promises,
expect(promise).rejects.toThrow()
throws an unexpected exception:Verified that without importing jest-dom, this issue does not occur.
Not sure if this is an issue from @testing-library/jest-dom, as the matcher that is broken seems unrelated. Furthermore, since @testing-library/jest-dom is relatively popular, I felt it would be useful to raise this issue here.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-6dgu5v?file=src%2F__tests__%2Findex.spec.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: