toContain/toMatch
assertion error doesn't show full string
#5266
Labels
toContain/toMatch
assertion error doesn't show full string
#5266
Describe the bug
Currently
toContain/toMatch
is delegated to chai's builtincontain/include/match
assertion and they don't enableshowDiff
:vitest/packages/expect/src/jest-expect.ts
Line 209 in 7d9b1fb
https://github.com/chaijs/chai/blob/61159d1a808af63ca64d9c57d582a624ab5761d9/lib/chai/core/assertions.js#L609-L614
Due to this, the error message from
toContain/toMatch
doesn't show full string while other assertions liketoEqual
do. To extend the truncated output inAssertionError: ...
, users need to tweakchaiConfig.truncateThreshold
https://vitest.dev/config/#chaiconfig-truncatethreshold and it feels like a minor papercut.I think we can cover at least simple cases like
expect(string).toMatch(string)
on our own and usethis.assert
to enableshowDiff
and letpretty-format
shows the diff (which I think currently doesn't handle do truncation though).Vitest Output
Also Jest output for comparison
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-argx1k?file=test%2Fbasic.test.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: