Skip to content

Commit

Permalink
add vitest test data plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vpiyachinda committed Feb 9, 2024
1 parent 837365a commit 1ca6a17
Show file tree
Hide file tree
Showing 7 changed files with 1,239 additions and 5 deletions.
35 changes: 35 additions & 0 deletions doc/VITEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Vitest Test Data

This package also supports collecting the test data of projects that are using Vitest (0.x).

## Usage

### Basic usage

#### Vitest

If you use **Vitest**, you can add the following to your `vitest.config.js` file:

```javascript
import { VitestTestDataPlugin } from '@agoda-com/test-metrics'

export default defineConfig({
...,
test: {
...,
reporters: ['default', new VitestTestDataPlugin()],
},
})
```

Don't forget to keep `'default'` reporter in the list, otherwise you won't be able to see your test result in the console.

### Advanced usage

As same as build time, test data collection also sends the command that you used to run the build like `yarn test` to be the custom identifier which should work in most cases in order to help you distinguish between different test configurations.

However, if you would like to define your own identifier, you can do so by passing it as a parameter to the plugin.

```javascript
VitestTestDataPlugin(testOnlyPartA ? 'test-only-part-a' : 'test-everything');
```
Loading

0 comments on commit 1ca6a17

Please sign in to comment.