feat(vitest): add github actions reporter#5093
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Should we enable it by default if GitHub Actions env is found? What does Bun do in this situation for example? The problem here is that it is impossible to disable then 🤔 |
So far I've been checking only Jest as a comparison (and make it somewhat compatible). Good point, I'll also check how Bun does this. |
|
Indeed, Bun automatically enables github actions style output based on To opt out, users would probably need to manually set To me, automatically disabling by checking non-existence of export default {
test: {
reporters: process.env.GITHUB_ACTIONS
? ['default', "github-actions"]
: 'default'
}
} |
Why do you think we cannot introduce it? Is it a breaking change? |
Description
The idea is to reuse the entire
printErrorutil used by "default" reporter:vitest/packages/vitest/src/node/reporters/base.ts
Line 371 in 8cc3eef
It looks like this mostly works with minor adjustment/fix of
printErrorside (though ideally it might make sense to refactor currentprintErrorto cover this kind of use case better).There are a few minor differences from sapphi-red's vitest-github-actions-reporter:
@actions/coredependencies are removed since it's only used for simple command formatting utilities (e.g.::error ...). I only copied minimally necessary code from https://github.com/actions/toolkit/tree/main/packages/core, which is also what Jest did in their reporter.printErrorutil.example output
In this commit c89aa5f, I tested demo test cases on CI and it looks like this:
Reveal screenshot
Also comparison to default reporter:
Also the same annotations appear in the summary https://github.com/vitest-dev/vitest/actions/runs/7749165463
todo / tbd
GITHUB_ACTIONSenv var?github-actionsreporter explicitly but disable it automatically ifGITHUB_ACTIONSis not defined. I did the same here.references
bun testoven-sh/bun#3071Please 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:.