feat(reporters): customize project name colors through options#7419
Closed
kevinmarrec wants to merge 1 commit intovitest-dev:mainfrom
kevinmarrec:reporter-colors
Closed
feat(reporters): customize project name colors through options#7419kevinmarrec wants to merge 1 commit intovitest-dev:mainfrom kevinmarrec:reporter-colors
kevinmarrec wants to merge 1 commit intovitest-dev:mainfrom
kevinmarrec:reporter-colors
Conversation
kevinmarrec
commented
Feb 4, 2025
| .reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0) | ||
|
|
||
| const colors = [c.black, c.yellow, c.cyan, c.green, c.magenta] | ||
| colors = typeof colors === 'function' ? colors(c) : colors |
Author
There was a problem hiding this comment.
Provides tinyrainbow :
{ colors: (c) => [c.blue, c.red] }We may only allow function type to keep things simpler.
kevinmarrec
commented
Feb 4, 2025
|
|
||
| if (benches.length > 0 && benches.every(t => t.result?.state !== 'run' && t.result?.state !== 'queued')) { | ||
| let title = `\n ${getStateSymbol(task)} ${formatProjectName(task.file.projectName)}${getFullName(task, c.dim(' > '))}` | ||
| let title = `\n ${getStateSymbol(task)} ${formatProjectName(task.file.projectName, { colors: this.colors })}${getFullName(task, c.dim(' > '))}` |
Author
There was a problem hiding this comment.
Sounds like little cumbersome, I'm open for refactoring for something like formatOptions
6 tasks
sheremet-va
requested changes
Feb 4, 2025
| private options: DefaultReporterOptions | ||
| private summary?: SummaryReporter | ||
|
|
||
| protected colors: DefaultReporterOptions['colors'] |
Member
There was a problem hiding this comment.
- Colors should also be inherited by UI, so limiting it to reporters won't work
- Since UI also requires colors, we can't use ANSII or functions, it should be hard coded names
Author
There was a problem hiding this comment.
Thank you for the feedback, I'll work on another solution.
Author
Closing this, will eventually work on a more suitable solution that would also work for Vitest UI. The option should be configured at upper level therefore |
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
Fixes #6481
Follows #7371
Introduce a
colorsreporter option to be able to customize what colors are used when formatting reporter outputs.Maybe what we would to introduce instead is the whole
formatProjectNamefunction override.Tests
I'd like some help to writing tests for this.
Documentation
Needs to be discussed, the option name is subject to change.