-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vitest): add github actions reporter #5093
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 https://github.com/sapphi-red/vitest-github-actions-reporter?tab=readme-ov-file#usage 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
printError
util 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
printError
side (though ideally it might make sense to refactor currentprintError
to cover this kind of use case better).There are a few minor differences from sapphi-red's vitest-github-actions-reporter:
@actions/core
dependencies 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.printError
util.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_ACTIONS
env var?github-actions
reporter explicitly but disable it automatically ifGITHUB_ACTIONS
is not defined. I did the same here.references
bun test
oven-sh/bun#3071Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.