feat: add logger.formatError#10268
Merged
sheremet-va merged 4 commits intovitest-dev:mainfrom May 5, 2026
Merged
Conversation
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Logger.formatErrorlogger.formatError
7 tasks
sheremet-va
approved these changes
May 5, 2026
|
Wonderful! many thanks @hi-ogawa 🫶 |
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
This PR adds
ctx.logger.formatError(error, options)as a side-effect-free counterpart toctx.logger.printError(...). Custom reporters can now reuse Vitest’s existing error formatting while writing the formatted output to their own sinks.This change also removes the redundant
options.taskfield, which leaked the internal runner task type into error formatting options. It was used for branching browser mode stack formatting but another optionoptions.projectis sufficient for the same purpose. Also, as a part of the migration, the built-in GitHub Actions and JUnit reporters now uselogger.formatError.Here are some other ways to expose the same API. I ended up with
logger.formatErroras it seems most natural place.A top-level
formatError(error, ctx, options)export would be simple, but it would introduce a new standalone reporter utility surface and still needctxfor config, stack filtering, source maps, browser parsing, and highlighting.ctx.formatError(error, options)would avoid a top-level export, but error formatting is logger/reporting behavior rather than coreVitestorchestration behavior.static DefaultReporter.formatError(error, ctx, options)would keep the helper near reporter APIs, but formatting is not specific toDefaultReporter, and it would still needctx.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:.