Skip to content

Commit

Permalink
Merge pull request #3 from agoda-com/vitest
Browse files Browse the repository at this point in the history
add vitest test data plugin
  • Loading branch information
vpiyachinda committed Feb 9, 2024
2 parents 837365a + bf3d695 commit 5bcde5d
Show file tree
Hide file tree
Showing 11 changed files with 1,391 additions and 31 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ if the version is not updated, delete node_modules folder and reinstall

The idea is you can publish the new version using `release` job on CI.

# for playwright
## for playwright
please read doc/PLAYWRIGHT.md

## for vitest
please read doc/VITEST.md
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 5bcde5d

Please sign in to comment.