@flakiness/vitest 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/lib/reporter.js +17076 -63
- package/package.json +18 -9
- package/types/src/reporter.d.ts +1 -10
- package/types/src/reporter.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ A custom Vitest reporter that generates Flakiness Reports from your Vitest test
|
|
|
13
13
|
- [Viewing Reports](#viewing-reports)
|
|
14
14
|
- [Features](#features)
|
|
15
15
|
- [Test Location Tracking](#test-location-tracking)
|
|
16
|
+
- [Attachments](#attachments)
|
|
16
17
|
- [Handling Test Duplicates](#handling-test-duplicates)
|
|
17
18
|
- [Environment Detection](#environment-detection)
|
|
18
19
|
- [CI Integration](#ci-integration)
|
|
@@ -29,6 +30,7 @@ A custom Vitest reporter that generates Flakiness Reports from your Vitest test
|
|
|
29
30
|
|
|
30
31
|
## Requirements
|
|
31
32
|
|
|
33
|
+
- Node.js 20.17.0 or higher (22.9.0 or higher on Node 22)
|
|
32
34
|
- Vitest 4.0 or higher
|
|
33
35
|
- Node.js project with a git repository (for commit information)
|
|
34
36
|
- Valid Flakiness.io access token (for uploads)
|
|
@@ -77,14 +79,27 @@ npx flakiness show ./flakiness-report
|
|
|
77
79
|
|
|
78
80
|
## Uploading Reports
|
|
79
81
|
|
|
80
|
-
Reports are automatically uploaded to Flakiness.io after test completion. Authentication
|
|
82
|
+
Reports are automatically uploaded to Flakiness.io after test completion. Authentication is resolved in the following order, and the first available method wins:
|
|
81
83
|
|
|
82
84
|
- **Access token**: Provide a token via the `token` option or the `FLAKINESS_ACCESS_TOKEN` environment variable.
|
|
83
|
-
- **GitHub OIDC**: When running in GitHub Actions, the reporter can authenticate using GitHub's OIDC token
|
|
85
|
+
- **GitHub OIDC**: When running in GitHub Actions with no access token, the reporter can authenticate using GitHub's OIDC token. This requires three conditions:
|
|
84
86
|
1. The `flakinessProject` option must be set to your Flakiness.io project identifier (`org/project`).
|
|
85
87
|
2. The Flakiness.io project must be bound to the GitHub repository that runs the GitHub Actions workflow.
|
|
88
|
+
3. The workflow must grant the `id-token: write` permission.
|
|
89
|
+
- **GitLab OIDC**: When running in GitLab CI/CD with no access token, the reporter can authenticate using a GitLab ID token. GitLab mints ID tokens when the job starts, so the job must declare one named `FLAKINESS_ID_TOKEN` whose audience is your project identifier:
|
|
86
90
|
|
|
87
|
-
|
|
91
|
+
```yaml
|
|
92
|
+
test:
|
|
93
|
+
id_tokens:
|
|
94
|
+
FLAKINESS_ID_TOKEN:
|
|
95
|
+
aud: my-org/my-project # must match the `flakinessProject` option
|
|
96
|
+
script:
|
|
97
|
+
- npx vitest run
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The `flakinessProject` option must be set, and the Flakiness.io project must be bound to the GitLab project running the pipeline.
|
|
101
|
+
|
|
102
|
+
If no method is available the upload is skipped, and if an upload fails the report is still available locally in the output folder. Either way the test run is unaffected.
|
|
88
103
|
|
|
89
104
|
## Viewing Reports
|
|
90
105
|
|
|
@@ -102,6 +117,17 @@ See [features.md](./features.md) for this reporter's status against the [Flakine
|
|
|
102
117
|
|
|
103
118
|
When `includeTaskLocation: true` is set in your Vitest config, the reporter records the exact file, line, and column for each test. This enables precise navigation from the Flakiness.io dashboard back to your source code.
|
|
104
119
|
|
|
120
|
+
### Attachments
|
|
121
|
+
|
|
122
|
+
[Browser Mode](https://vitest.dev/guide/browser/) records screenshots as Vitest artifacts. The reporter writes them into the local Flakiness report and uploads them along with it. Identical content is stored only once, no matter how many tests attach it.
|
|
123
|
+
|
|
124
|
+
Two kinds of screenshot are captured:
|
|
125
|
+
|
|
126
|
+
- **Failure screenshots.** Vitest screenshots every failing test when [`browser.screenshotFailures`](https://vitest.dev/config/browser/screenshotfailures) is enabled — which is the default outside of the Vitest UI. It is reported as `failure-screenshot.png`, and needs no changes to your tests.
|
|
127
|
+
- **Visual regressions.** Each failed `toMatchScreenshot()` comparison contributes `screenshot-1-expected.png`, `screenshot-1-actual.png` and `screenshot-1-diff.png`, numbered per comparison within the test. Vitest does not take a failure screenshot for these, since the comparison images already show the page.
|
|
128
|
+
|
|
129
|
+
Attachments of custom artifacts recorded through Vitest's `recordArtifact()` are named after the artifact type (`my-plugin:artifact-1`). Attachments of test annotations (`context.annotate()`) are not collected.
|
|
130
|
+
|
|
105
131
|
### Handling Test Duplicates
|
|
106
132
|
|
|
107
133
|
Vitest allows creating tests with identical names:
|
|
@@ -175,7 +201,7 @@ reporters: [
|
|
|
175
201
|
|
|
176
202
|
### `flakinessProject?: string`
|
|
177
203
|
|
|
178
|
-
The Flakiness.io project identifier in `org/project` format.
|
|
204
|
+
The Flakiness.io project identifier in `org/project` format. Required for CI OIDC authentication. When set, and when the Flakiness.io project is bound to the repository running the pipeline, the reporter authenticates uploads via a GitHub Actions or GitLab CI/CD OIDC token with no access token required. See [Uploading Reports](#uploading-reports) for the per-provider requirements.
|
|
179
205
|
|
|
180
206
|
```typescript
|
|
181
207
|
reporters: [
|
|
@@ -199,7 +225,7 @@ reporters: [
|
|
|
199
225
|
|
|
200
226
|
Access token for authenticating with Flakiness.io when uploading reports. Defaults to the `FLAKINESS_ACCESS_TOKEN` environment variable.
|
|
201
227
|
|
|
202
|
-
If no token is provided, reporter
|
|
228
|
+
If no token is provided, the reporter falls back to CI OIDC on GitHub Actions and GitLab CI/CD. If that is unavailable too, the report is still generated locally but won't be uploaded automatically.
|
|
203
229
|
|
|
204
230
|
```typescript
|
|
205
231
|
reporters: [
|
|
@@ -253,6 +279,7 @@ The reporter respects the following environment variables:
|
|
|
253
279
|
- **`FLAKINESS_ENDPOINT`**: Custom Flakiness.io endpoint URL (equivalent to `endpoint` option)
|
|
254
280
|
- **`FLAKINESS_OUTPUT_DIR`**: Output directory for reports (equivalent to `outputFolder` option)
|
|
255
281
|
- **`FLAKINESS_DISABLE_UPLOAD`**: When set, disables report uploads (equivalent to `disableUpload` option)
|
|
282
|
+
- **`FLAKINESS_ID_TOKEN`**: GitLab CI/CD ID token used for OIDC authentication. Set by GitLab for jobs that declare it under `id_tokens:` (see [Uploading Reports](#uploading-reports))
|
|
256
283
|
|
|
257
284
|
## Example Configuration
|
|
258
285
|
|