refactor!: replace loupe.inspect with pretty-format#9609
Draft
hi-ogawa wants to merge 48 commits intovitest-dev:mainfrom
Draft
refactor!: replace loupe.inspect with pretty-format#9609hi-ogawa wants to merge 48 commits intovitest-dev:mainfrom
loupe.inspect with pretty-format#9609hi-ogawa wants to merge 48 commits intovitest-dev:mainfrom
Conversation
loupe.inspect with pretty-formatloupe.inspect with pretty-format
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Cover value types (primitives, collections, built-ins), existing options (indent, maxDepth, maxWidth, min, compareKeys, callToJSON, escapeString, escapeRegex, printBasicPrototype, printFunctionName), new PR options (singleQuote, quoteKeys, spacingInner, spacingOuter), ErrorPlugin, and custom plugin API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add INSPECT_OPTIONS and prettyInspect() as the unified replacement for inspect() and objDisplay(). Uses stringify with inspect-like options (singleQuote, quoteKeys: false, min, spaced) and surface-level truncation (structural summaries for containers, ellipsis for scalars). Refactor conformance tests to use prettyInspect from @vitest/utils/display instead of a local wrapper with duplicated options. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hi-ogawa
commented
Mar 6, 2026
Comment on lines
-282
to
-294
| describe('objDisplay', () => { | ||
| test.each` | ||
| value | expected | ||
| ${'a'.repeat(100)} | ${`'${'a'.repeat(37)}…'`} | ||
| ${'🐱'.repeat(100)} | ${`'${'🐱'.repeat(18)}…'`} | ||
| ${`a${'🐱'.repeat(100)}…`} | ${`'a${'🐱'.repeat(18)}…'`} | ||
| `('Do not truncate strings anywhere but produce valid unicode strings for $value', ({ value, expected }) => { | ||
| // encodeURI can be used to detect invalid strings including invalid code-points | ||
| // note: our code should not split surrogate pairs, but may split graphemes | ||
| expect(() => encodeURI(objDisplay(value))).not.toThrow() | ||
| expect(objDisplay(value)).toEqual(expected) | ||
| }) | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
Similar test exists in pretty-format.test.ts, so removed from here.
7 tasks
This was referenced Apr 2, 2026
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
hi-ogawa
commented
Apr 7, 2026
Collaborator
Author
There was a problem hiding this comment.
This is moved from test/config/test/chai-config.test.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pretty-formatandinspect#9582TODO
maxWidthwith displaying truncated count (e.g.[ 0, 1, 2, ...(7) ])taskTitleValueFormatTruncate: number(what a silly name...)Summary
loupedependency in@vitest/utilswith@vitest/pretty-formatfor all value inspection (test titles, error display, assertion messages (onlytoHavePropertywas usingobjDisplaydirectly))inspect(),objDisplay(),baseFormat(),format(), andbrowserFormat()into two clean exports:inspect()andformat()@vitest/pretty-format:inspectstyle formatting, new options are added, but there are still some discrepeancy.pretty-format.test.tsshould show almost full coverage including how three inspects (vitest, node, loupe) differ each other.@vitest/utils/displayexports:inspect(obj, loupeOptions)inspect(obj, { truncate?, multiline? ... })objDisplay(obj, loupeOptions)inspectwithtruncate)format(...args)format(args, options?)— signature changed from rest params to arraybrowserFormat(...args)format(args, { multiline: true }))baseFormat(args, options)format)Breaking changes
Since this changes
test.for/eachtitle formatting, this is considered a breaking change.Question: truncation config
For
test.for/eachtitle object formatting, the old behavior supported configuring truncation throughchaiConfig.truncateThresholdwith defaulttruncate: 40. This PR inherits the same behavior, but I think we should introduce a separate option since we now own the formatting and relevant to chai nor loupe. Perhaps, this can be follow-up.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.