-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: annotation API #7953
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: annotation API #7953
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
For now, UI only shows annotations in test files. In the future we will add a separate UI tab for everything related to the test itself (this is out of scope of 3.2). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! Didn't check tests yet.
Description
This PR adds a new
annotations
field to theTestCase
and anannotate
method attached to theTestContext
. In the reporter, you can get annotations fromtestCase.annotations()
or inonTestCaseAnnotate
event.onTestCaseAnnotate
is asynchronous and doesn't block test execution.Reporters display these annotations differently:
verbose
reporter in non-tty mode prints annotations after every test immediatelydefault
reporter prints them if there was an error in the testtap
reporter prints them in#
commentjunit
prints them insideproperties/attachment
github-actions
shows the annotation simillar to errorsui
reporter prints them in a "Report" tab and inside the test file (inlined)Annotations can also have attachments that will be shown in UI. These attachments are stored in
.vitest-attachments
folder.To add an annotation, you call
ctx.annotate
method:UI example (WIP):
Please 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:
.