Skip to content

fix(pretty-format): limit output for large object#9949

Merged
sheremet-va merged 14 commits intovitest-dev:mainfrom
hi-ogawa:fix-pretty-format-prevent-string-length-limit-on-large-object
Mar 23, 2026
Merged

fix(pretty-format): limit output for large object#9949
sheremet-va merged 14 commits intovitest-dev:mainfrom
hi-ogawa:fix-pretty-format-prevent-string-length-limit-on-large-object

Conversation

@hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Mar 23, 2026

Description

Several approaches is mentioned in the note above. This PR took the simplest approach inspired by Node's util.inspect. See 2nd approach in the note.

This doesn't necessarily supersede #9920 since that's more about heuristics of improving the error diff for obvious case. This PR is only about implementing the guard for worst case.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Mar 23, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f1f981e
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69c0dff32f374f0008a05e13
😎 Deploy Preview https://deploy-preview-9949--vitest-dev.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 project configuration.

hi-ogawa and others added 3 commits March 23, 2026 14:26
Change kill-switch from maxDepth = -1 to maxDepth = 0 (equivalent
behavior, clearer intent). Add test suite visualizing the budget
behavior: early elements expanded, later elements folded.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hi-ogawa hi-ogawa changed the title fix(pretty-format): prevent string length limit on large object fix(pretty-format): limit long formatting output of large object Mar 23, 2026
@hi-ogawa hi-ogawa changed the title fix(pretty-format): limit long formatting output of large object fix(pretty-format): limit formatting output for large object Mar 23, 2026
@hi-ogawa hi-ogawa changed the title fix(pretty-format): limit formatting output for large object fix(pretty-format): limit output for large object Mar 23, 2026
hi-ogawa and others added 2 commits March 23, 2026 16:13
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hi-ogawa hi-ogawa marked this pull request as ready for review March 23, 2026 07:29
@sheremet-va sheremet-va merged commit 0d5f9d6 into vitest-dev:main Mar 23, 2026
15 of 16 checks passed
@hi-ogawa hi-ogawa deleted the fix-pretty-format-prevent-string-length-limit-on-large-object branch March 23, 2026 10:25
@silverwind
Copy link
Contributor

silverwind commented Mar 25, 2026

This is a breaking change imho as it breaks existing snapshots that are above 1MB, should have been labeled as such.

@Marsup
Copy link

Marsup commented Mar 26, 2026

Broke some of our tests as well. I could see how this is a bug fix, but I don't understand how we can set this limit, is it not possible or just undocumented?

@hi-ogawa
Copy link
Collaborator Author

This had a bug. Would appreciate if you can try it out next attempt with loose and likely more reasonable default limit. #9965 (comment)

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.

expect(object).toBeUndefined causes memory leak

4 participants