feat(reporter): add filterMeta option to json reporter#10078
feat(reporter): add filterMeta option to json reporter#10078sheremet-va merged 5 commits intovitest-dev:mainfrom
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
AriPerkkio
left a comment
There was a problem hiding this comment.
Looks good. Though I would rather name this just filterMeta. Thoughts @sheremet-va (#8741 (comment)) ?
| location: t.location, | ||
| meta: t.meta, | ||
| meta: filterMetaField | ||
| ? Object.fromEntries( |
There was a problem hiding this comment.
It pains me to see this tbh. I don't think it matters much since meta is usually pretty small, but 3 iterations over the same array is mental 🦀
There was a problem hiding this comment.
Replaced with a single for...of loop.
There was a problem hiding this comment.
There are still two loops, you don't need Object.entries, you can use for in loop
There was a problem hiding this comment.
Done, changed to for...in loop.
There was a problem hiding this comment.
Thanks, sorry for being pedantic, I would've accepted forof if PR started as such 😄
There was a problem hiding this comment.
Thanks for the note, I'll keep that in mind.
|
|
||
| export interface JsonOptions { | ||
| outputFile?: string | ||
| filterMetaField?: (key: string, value: unknown) => boolean |
There was a problem hiding this comment.
I think we should support move return values (like filter does) - truthy/falsy
There was a problem hiding this comment.
Changed the return type to unknown and updated.
docs/guide/reporters.md
Outdated
| test: { | ||
| reporters: [ | ||
| ['json', { | ||
| filterMetaField: (key, value) => key !== 'internalField', |
There was a problem hiding this comment.
Yeah, my idea was just a proposal for a potential option. filterMeta sounds fine to me
There was a problem hiding this comment.
Renamed to filterMeta.
|
Addressed all review comments. Could you take another look? |
|
|
||
| export interface JsonOptions { | ||
| outputFile?: string | ||
| filterMeta?: (key: string, value: unknown) => unknown |
There was a problem hiding this comment.
If you mark this as @experimental, we can release it in the next fix
There was a problem hiding this comment.
I added /** @experimental */ to the filterMeta option in JsonOptions.
Description
Resolves #8741
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:.