-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(reporters): .vitest results directory convention
#9993
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
Open
AriPerkkio
wants to merge
1
commit into
vitest-dev:main
Choose a base branch
from
AriPerkkio:docs/reporter-directory-convention
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,29 @@ class MyReporter implements Reporter { | |
| } | ||
| ``` | ||
|
|
||
| ## Storing artifacts on file system | ||
|
|
||
| If your custom reporter needs to store any artifacts on file system it should place them inside `.vitest` directory. This directory is a convention that Vitest reporters and third party integrations can use to co-locate their results in a single directory. This way users of your custom reporter do not need to add multiple exclusion in their `.gitignore`. Only the `.vitest` is needed. | ||
|
|
||
| Reporters and other integrations should respect following rules around `.vitest` directory: | ||
|
|
||
| - `.vitest` directory is placed in [the `root` of the project](/config/root) | ||
| - Reporter can create `.vitest` directory if it does not already exist | ||
| - Reporter should never remove `.vitest` directory | ||
| - Reporter should create their own directory inside `.vitest`, for example `.vitest/yaml-reporter/` | ||
| - Reporter can remove their own specific directory inside `.vitest`, for example `.vitest/yaml-reporter/` | ||
|
|
||
| ```ansi | ||
| .vitest | ||
| │ | ||
| ├── yaml-reporter | ||
| │ ├── results.yaml | ||
| │ └── summary.yaml | ||
| │ | ||
| └── junit-reporter | ||
| └── report.xml | ||
| ``` | ||
|
|
||
|
Comment on lines
+75
to
+97
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ## Exported Reporters | ||
|
|
||
| `vitest` comes with a few [built-in reporters](/guide/reporters) that you can use out of the box. | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,13 @@ It is recommended that you install a copy of `vitest` in your `package.json`, us | |
|
|
||
| The `npx` tool will execute the specified command. By default, `npx` will first check if the command exists in the local project's binaries. If it is not found there, `npx` will look in the system's `$PATH` and execute it if found. If the command is not found in either location, `npx` will install it in a temporary location prior to execution. | ||
|
|
||
| Vitest and third party integrations can use `.vitest` directory to store generated artifacts. It's recommended to add this in your `.gitignore`. | ||
|
|
||
| ``` sh [.gitignore] | ||
| # Vitest reports and artifacts | ||
| .vitest/ | ||
| ``` | ||
|
|
||
|
Comment on lines
+46
to
+52
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ## Writing Tests | ||
|
|
||
| As an example, we will write a simple test that verifies the output of a function that adds two numbers. | ||
|
|
||
Oops, something went wrong.
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.
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.
Should we make it simpler for custom reporters to use this convention by exposing utilities on something like
vitest.report?vitest.report.writeFilevitest.report.deleteFilevitest.report.readFileIt accepts a file relative to
.vitestfolder. If.vitestfolder doesn't exist, we create it. This could also be useful for internal reporters.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.
Sounds good - anything to make it easier for users to follow these guidelines.
Maybe it something like:
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.
Sounds good