diff --git a/.github/workflows/CI-pipeline.yml b/.github/workflows/CI-pipeline.yml
index 1d16d38..c4621ac 100644
--- a/.github/workflows/CI-pipeline.yml
+++ b/.github/workflows/CI-pipeline.yml
@@ -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
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 27a2400..adda934 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -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
@@ -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'
@@ -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'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a6ab6b0..2cb58f1 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -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: |
@@ -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
@@ -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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69fc153..779c2f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+### Added
+- ReportingApi with attachment support
+- `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
diff --git a/README.md b/README.md
index 68b446f..9930975 100644
--- a/README.md
+++ b/README.md
@@ -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)],
},
});
@@ -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. |
@@ -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).
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:
@@ -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.
+ ```javascript
+ test('should contain logs with attachments',() => {
+ ...
+ ReportingApi.attachment({ name, type, content }, 'Description');
+ ...
+ });
+ ```
+
+- Import `ReportingApi` from `'@reportportal/agent-js-vitest'`:
+ ```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.
+ ```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.
+
+##### attachment
+Send file to ReportPortal for the current test. Should be called inside of corresponding test.
+`ReportingApi.attachment(task: vitest.Task, data: Attachment, description?: string);`
+**required**: `task`, `data`
+**optional**: `description`
+where `Attachment` type is `{name: string; type: string; content: string | Buffer;}`
+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);
+});
+```
diff --git a/VERSION b/VERSION
index 0062ac9..4f76215 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.0.0
+5.0.1-SNAPSHOT
diff --git a/package-lock.json b/package-lock.json
index 9ae3b8d..0a717a7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6,10 +6,10 @@
"packages": {
"": {
"name": "@reportportal/agent-js-vitest",
- "version": "4.0.0",
+ "version": "5.0.0",
"license": "Apache-2.0",
"dependencies": {
- "@reportportal/client-javascript": "^5.1.1"
+ "@reportportal/client-javascript": "^5.1.3"
},
"devDependencies": {
"@types/jest": "^29.5.12",
@@ -31,7 +31,7 @@
"vitest": "^1.2.2"
},
"engines": {
- "node": ">=14.x"
+ "node": ">=16.x"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@@ -1765,13 +1765,13 @@
}
},
"node_modules/@reportportal/client-javascript": {
- "version": "5.1.1",
- "resolved": "https://registry.npmjs.org/@reportportal/client-javascript/-/client-javascript-5.1.1.tgz",
- "integrity": "sha512-GgWRODR4twqFkBMSDhsck4JZVeIJPRLMuNjbypnCJXbvZ8JYMJoMk30Mw5M9QGByAFFrpZZ7Ih9pXCsccxscSA==",
+ "version": "5.1.3",
+ "resolved": "https://registry.npmjs.org/@reportportal/client-javascript/-/client-javascript-5.1.3.tgz",
+ "integrity": "sha512-1/utoKnHUgiilR6Ep8pHvuNZGv5oDeI+x1/aJNu8IADoVG1U0Q4tB2trWHDIY07T/PCzrnzp6dVcCu/wLsdVRA==",
"dependencies": {
- "axios": "^1.6.5",
- "axios-retry": "^4.0.0",
- "glob": "^7.2.3",
+ "axios": "^1.6.8",
+ "axios-retry": "^4.1.0",
+ "glob": "^8.1.0",
"ini": "^2.0.0",
"uniqid": "^5.4.0",
"uuid": "^9.0.1"
@@ -1780,6 +1780,43 @@
"node": ">=12.x"
}
},
+ "node_modules/@reportportal/client-javascript/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/@reportportal/client-javascript/node_modules/glob": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
+ "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^5.0.1",
+ "once": "^1.3.0"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/@reportportal/client-javascript/node_modules/minimatch": {
+ "version": "5.1.6",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
+ "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.10.0.tgz",
@@ -2713,19 +2750,19 @@
}
},
"node_modules/axios": {
- "version": "1.6.7",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
- "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
+ "version": "1.6.8",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
+ "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"dependencies": {
- "follow-redirects": "^1.15.4",
+ "follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios-retry": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.0.0.tgz",
- "integrity": "sha512-F6P4HVGITD/v4z9Lw2mIA24IabTajvpDZmKa6zq/gGwn57wN5j1P3uWrAV0+diqnW6kTM2fTqmWNfgYWGmMuiA==",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.1.0.tgz",
+ "integrity": "sha512-svdth4H00yhlsjBbjfLQ/sMLkXqeLxhiFC1nE1JtkN/CIssGxqk0UwTEdrVjwA2gr3yJkAulwvDSIm4z4HyPvg==",
"dependencies": {
"is-retry-allowed": "^2.2.0"
},
@@ -2858,6 +2895,7 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -3137,7 +3175,8 @@
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+ "dev": true
},
"node_modules/confusing-browser-globals": {
"version": "1.0.11",
@@ -4218,9 +4257,9 @@
"dev": true
},
"node_modules/follow-redirects": {
- "version": "1.15.5",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
- "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
+ "version": "1.15.6",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
@@ -4401,6 +4440,7 @@
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
+ "dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@@ -5964,6 +6004,7 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@@ -6286,6 +6327,7 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
+ "dev": true,
"engines": {
"node": ">=0.10.0"
}
diff --git a/package.json b/package.json
index fe886a9..e20167b 100644
--- a/package.json
+++ b/package.json
@@ -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"
@@ -57,5 +68,11 @@
"reports",
"portal",
"epam"
+ ],
+ "contributors": [
+ {
+ "name": "Ilya Hancharyk",
+ "email": "amsterget@gmail.com"
+ }
]
}
diff --git a/src/index.ts b/src/index.ts
index 7654653..812f3ad 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -16,7 +16,12 @@
*/
import { RPReporter } from './reporter';
+import { ReportingApi } from './reportingApi';
+import { GlobalReportingApi } from './models';
-export { RPReporter };
+declare global {
+ const ReportingApi: GlobalReportingApi;
+}
+export { RPReporter, ReportingApi };
export default RPReporter;
diff --git a/src/models/configs.ts b/src/models/configs.ts
index 2e37334..c1c4301 100644
--- a/src/models/configs.ts
+++ b/src/models/configs.ts
@@ -48,4 +48,5 @@ export interface ReportPortalConfig extends ClientConfig {
// agent specific options
skippedIssue?: boolean;
+ extendTestDescriptionWithLastError?: boolean;
}
diff --git a/src/models/index.ts b/src/models/index.ts
index 9ca6df5..516d5aa 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -21,6 +21,9 @@ import {
FinishTestItemObjType,
LogRQ,
Attachment,
+ RPTaskMeta,
+ ReportingApi,
+ GlobalReportingApi,
} from './reporting';
import { ReportPortalConfig } from './configs';
import { Attribute } from './common';
@@ -32,5 +35,8 @@ export {
ReportPortalConfig,
Attachment,
Attribute,
+ RPTaskMeta,
+ ReportingApi,
+ GlobalReportingApi,
LogRQ,
};
diff --git a/src/models/reporting.ts b/src/models/reporting.ts
index 0f4de28..c9ea153 100644
--- a/src/models/reporting.ts
+++ b/src/models/reporting.ts
@@ -14,7 +14,8 @@
* limitations under the License.
*
*/
-
+// eslint-disable-next-line import/named
+import { Task, TaskMeta } from 'vitest';
import { Attribute, Issue } from './common';
import { TEST_ITEM_TYPES, LOG_LEVELS, LAUNCH_MODES } from '../constants';
@@ -61,3 +62,19 @@ export interface LogRQ {
time?: number;
file?: Attachment;
}
+
+export interface RPTaskMeta extends TaskMeta {
+ rpMeta: {
+ test: {
+ logs: LogRQ[];
+ };
+ };
+}
+
+export interface ReportingApi {
+ attachment: (context: Task, data: Attachment, description?: string) => void;
+}
+
+export interface GlobalReportingApi {
+ attachment: (data: Attachment, description?: string) => void;
+}
diff --git a/src/reporter.ts b/src/reporter.ts
index e02fc46..0545a11 100644
--- a/src/reporter.ts
+++ b/src/reporter.ts
@@ -33,6 +33,7 @@ import {
getCodeRef,
getBasePath,
isErrorLog,
+ isRPTaskMeta,
} from './utils';
import {
LAUNCH_MODES,
@@ -69,6 +70,7 @@ export class RPReporter implements Reporter {
constructor(config: ReportPortalConfig) {
this.config = {
+ extendTestDescriptionWithLastError: true,
...config,
launchId: process.env.RP_LAUNCH_ID || config.launchId,
};
@@ -165,17 +167,30 @@ export class RPReporter implements Reporter {
const packsReversed = [...packs];
packsReversed.reverse();
- for (const [id, taskResult] of packsReversed) {
+ for (const [id, taskResult, meta] of packsReversed) {
const testItem = this.testItems.get(id);
const { id: testItemId, finishSend } = testItem || {};
if (!testItemId || finishSend || !FINISHED_STATES.includes(taskResult?.state)) {
continue;
}
+ if (isRPTaskMeta(meta)) {
+ meta.rpMeta.test.logs.forEach((logRq) => {
+ this.sendLog(testItemId, logRq);
+ });
+ }
+
const finishTestItemObj = this.getFinishTestItemObj(taskResult);
if (taskResult?.errors?.length) {
const error = taskResult.errors[0];
+
+ if (this.config.extendTestDescriptionWithLastError) {
+ finishTestItemObj.description = (finishTestItemObj.description || '').concat(
+ `\n\`\`\`error\n${error.stack}\n\`\`\``,
+ );
+ }
+
const logRq: LogRQ = {
time: finishTestItemObj.endTime,
level: LOG_LEVELS.ERROR,
diff --git a/src/reportingApi.ts b/src/reportingApi.ts
new file mode 100644
index 0000000..992679a
--- /dev/null
+++ b/src/reportingApi.ts
@@ -0,0 +1,36 @@
+import * as vitest from 'vitest';
+import * as Models from './models';
+import { isRPTaskMeta } from './utils';
+
+const injectRPTaskMeta = (task: vitest.Task) => {
+ if (isRPTaskMeta(task.meta)) {
+ return;
+ }
+
+ (task.meta as Models.RPTaskMeta) = {
+ ...task.meta,
+ rpMeta: {
+ test: {
+ logs: [],
+ },
+ },
+ };
+};
+
+const attachment = (task: vitest.Task, data: Models.Attachment, description?: string) => {
+ injectRPTaskMeta(task);
+ (task.meta as Models.RPTaskMeta).rpMeta.test.logs.push({
+ file: data,
+ time: Date.now(),
+ message: description || data.name,
+ });
+};
+
+export const ReportingApi: Models.ReportingApi = {
+ attachment,
+};
+
+export const bindReportingApi = (task: vitest.Task): Models.GlobalReportingApi => ({
+ attachment: (data: Models.Attachment, description?: string) =>
+ attachment(task, data, description),
+});
diff --git a/src/scripts/setup.js b/src/scripts/setup.js
new file mode 100644
index 0000000..4c50e99
--- /dev/null
+++ b/src/scripts/setup.js
@@ -0,0 +1,12 @@
+import { afterEach, beforeEach } from 'vitest';
+import { bindReportingApi } from '../reportingApi';
+
+beforeEach(async (ctx) => {
+ // @ts-ignore
+ global.ReportingApi = bindReportingApi(ctx.task);
+});
+
+afterEach(() => {
+ // @ts-ignore
+ global.ReportingApi = undefined;
+});
diff --git a/src/types/interfaces.d.ts b/src/types/interfaces.d.ts
index a13f5e0..e2ef1b1 100644
--- a/src/types/interfaces.d.ts
+++ b/src/types/interfaces.d.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*
*/
+import * as vitest from 'vitest';
declare namespace Interfaces {
interface Attribute {
@@ -38,4 +39,12 @@ declare namespace Interfaces {
interface ObjUniversal {
[name: string]: string;
}
+
+ interface ReportingApi {
+ attachment: (task: vitest.Task, data: Attachment, description?: string) => void;
+ }
+
+ interface GlobalReportingApi {
+ attachment: (data: Attachment, description?: string) => void;
+ }
}
diff --git a/src/utils.ts b/src/utils.ts
index 9976f47..c186bd9 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -16,9 +16,10 @@
*/
import { normalize, sep } from 'node:path';
+import * as vitest from 'vitest';
// @ts-ignore
import { name as pjsonName, version as pjsonVersion } from '../package.json';
-import { Attribute } from './models';
+import { Attribute, RPTaskMeta } from './models';
export const isFalse = (value: string | boolean | undefined): boolean =>
[false, 'false'].includes(value);
@@ -63,3 +64,6 @@ export const getCodeRef = (basePath: string, itemTitle: string): string =>
export const isErrorLog = (message: string): boolean => {
return message.toLowerCase().includes('error');
};
+
+export const isRPTaskMeta = (meta: vitest.TaskMeta | RPTaskMeta): meta is RPTaskMeta =>
+ 'rpMeta' in meta;
diff --git a/tsconfig.json b/tsconfig.json
index f6bec20..8dd3ba3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -18,5 +18,5 @@
"outDir": "./build"
},
"include": ["./src/**/*"],
- "exclude": ["node_modules", "src/__tests__"]
+ "exclude": ["node_modules", "src/__tests__", "src/scripts"]
}
diff --git a/version_fragment b/version_fragment
index 9eb7b90..acb503f 100644
--- a/version_fragment
+++ b/version_fragment
@@ -1 +1 @@
-patch
+minor