Skip to content
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

Release 5.1.0 #18

Merged
merged 13 commits into from
May 3, 2024
Merged
4 changes: 2 additions & 2 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install of node dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install of node dependencies
Expand All @@ -41,9 +41,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
Expand All @@ -59,7 +59,7 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Read version
id: readVersion
run: |
Expand Down Expand Up @@ -78,9 +78,9 @@ jobs:
versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '12'
- name: Configure git
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Release
id: createRelease
uses: actions/create-release@v1
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Added
- ReportingApi with attachment support
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved
- `extendTestDescriptionWithLastError` option to the RP config to be able to toggle the last error log attaching to the test description.
### Changed
- `@reportportal/client-javascript` bumped to version `5.1.3`.

## [5.0.0] - 2024-02-15
### Added
Expand Down
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ npm install --save-dev @reportportal/agent-js-vitest

export default defineConfig({
test: {
// add setup file to be able to use ReportingApi via `this.ReportingApi` in your tests
setupFiles: ["@reportportal/agent-js-vitest/setup"],
reporters: ['default', new RPReporter(rpConfig)],
},
});
Expand All @@ -46,7 +48,7 @@ The full list of available options presented below.
| Option | Necessity | Default | Description |
|---------------------------------------------|------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| apiKey | Required | | User's ReportPortal token from which you want to send requests. It can be found on the profile page of this user. |
| endpoint | Required | | URL of your server. For example 'https://server:8080/api/v1'. |
| endpoint | Required | | URL of your server. For example 'https://server:8080/api/v2'. |
| launch | Required | | Name of launch at creation. |
| project | Required | | The name of the project in which the launches will be created. |
| attributes | Optional | [] | Launch attributes. |
Expand All @@ -59,6 +61,7 @@ The full list of available options presented below.
| restClientConfig | Optional | Not set | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests). <br/> Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. |
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`. |
| extendTestDescriptionWithLastError | Optional | true | If set to `true` the latest error log will be attached to the test case description. |

The following options can be overridden using ENVIRONMENT variables:

Expand Down Expand Up @@ -94,3 +97,67 @@ console.error();
console's `log`, `info`,`dubug` reports as info log.

console's `error`, `warn` reports as error log if message contains _error_ mention, otherwise as warn log.

### Reporting API

This reporter provides Reporting API to use it directly in tests to send some additional data to the report.

To start using the `ReportingApi` in tests, you can:
- Add setup file in `vitest.config.ts`
```javascript
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
...
setupFiles: ["@reportportal/agent-js-vitest/setup"],
},
});
```
`ReportingApi` will be available in global variables and supports receiving `task` from the `setup` file.
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved
```javascript
test('should contain logs with attachments',() => {
...
ReportingApi.attachment({ name, type, content }, 'Description');
...
});
```

- Import `ReportingApi` from `'@reportportal/agent-js-vitest'`:
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved
```javascript
import { ReportingApi } from '@reportportal/agent-js-vitest';
```
In this case you are required to pass `task` as the first argument to the `ReportingApi` methods.
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved
```javascript
test('should contain logs with attachments',({ task }) => {
...
ReportingApi.attachment(task, { name, type, content }, 'Description');
...
});
```

#### Reporting API methods

The API provide methods for attaching data.<br/>
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved

##### attachment
Send file to ReportPortal for the current test. Should be called inside of corresponding test.<br/>
AliakseiLiasnitski marked this conversation as resolved.
Show resolved Hide resolved
`ReportingApi.attachment(task: vitest.Task, data: Attachment, description?: string);`<br/>
**required**: `task`, `data`<br/>
**optional**: `description`<br/>
where `Attachment` type is `{name: string; type: string; content: string | Buffer;}`<br/>
Example:
```javascript
test('should contain logs with attachments',({ task }) => {
const fileName = 'test.jpg';
const fileContent = fs.readFileSync(path.resolve(__dirname, './attachments', fileName));

ReportingApi.attachment(task, {
name: fileName,
type: 'image/png',
content: fileContent.toString('base64'),
}, 'Description');

expect(true).toBe(true);
});
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0
5.0.1-SNAPSHOT
82 changes: 62 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@
"description": "Agent to integrate Vitest with ReportPortal.",
"main": "build/index.js",
"types": "build/index.d.ts",
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.js"
},
"./setup": {
"import": "./build/scripts/setup.js",
"require": "./build/scripts/setup.js"
}
},
"scripts": {
"build": "npm run clean && tsc",
"clean": "rimraf ./build",
"lint": "eslint \"src/**/*.ts\"",
"format": "npm run lint -- --fix",
"postbuild": "mkdir -p build && cp -R src/scripts build/",
"test": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@reportportal/client-javascript": "^5.1.1"
"@reportportal/client-javascript": "^5.1.3"
},
"files": [
"/build"
Expand Down Expand Up @@ -57,5 +68,11 @@
"reports",
"portal",
"epam"
],
"contributors": [
{
"name": "Ilya Hancharyk",
"email": "amsterget@gmail.com"
}
]
}
Loading
Loading