Open CornCobs opened 6 months ago
It looks like server.deps.inline: true
is also a necessary factor to reproduce this. I feel it's a bit dangerous flag since it looks like it's also inlining vitest
, @vitest/runner
, etc... and actually it doesn't seem to even work when running the most basic template https://stackblitz.com/edit/vitest-dev-vitest-rlq7to?file=vite.config.ts
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 inline: true
Confirmed that modifying server.deps.inline to an array of package names worked.
https://github.com/chaijs/check-error/issues/51
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:
➜ ~/s/peated (ref/collapse-worker) ✗ cat pnpm-lock.yaml| grep jest
/@jest/schemas@29.6.3:
eslint-plugin-jest: 26.9.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.57.0)(typescript@5.3.3)
eslint-plugin-jest-dom: 4.0.3(eslint@8.57.0)
- jest
/eslint-plugin-jest-dom@4.0.3(eslint@8.57.0):
/eslint-plugin-jest@26.9.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.57.0)(typescript@5.3.3):
jest: '*'
jest:
'@jest/schemas': 29.6.3
@dcramer Do you use server.deps.inline
?
@hi-ogawa not afaik https://github.com/dcramer/peated/blob/main/apps/server/vitest.config.ts
I thought this is sever.deps.inline: true
only issue, but maybe I was wrong. Last time I checked, globals: true
seems also relevant, so maybe that one is the factor.
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.
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