transit-core-taf 1.0.7 → 1.0.8
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/dist/transit-core-taf/index.d.ts +1 -1
- package/dist/transit-core-taf/index.js +6 -1
- package/dist/transit-core-taf/reporters/testrail-reporter.d.ts +11 -1
- package/dist/transit-core-taf/reporters/testrail-reporter.js +14 -16
- package/dist/transit-core-taf/utils/testrail/client.js +1 -1
- package/package.json +1 -2
|
@@ -9,5 +9,5 @@ export * from './utils/Utils';
|
|
|
9
9
|
export * from './baseapi/baseapihelpers';
|
|
10
10
|
export * from './baseapi/apiutils';
|
|
11
11
|
export * from './constants/test-tags';
|
|
12
|
-
export
|
|
12
|
+
export { default as TestRailReporter, TestRailReporterOptions } from './reporters/testrail-reporter';
|
|
13
13
|
export * from './utils/testrail/client';
|
|
@@ -13,7 +13,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TestRailReporter = void 0;
|
|
17
21
|
__exportStar(require("./baseui/basepagevalidations"), exports);
|
|
18
22
|
__exportStar(require("./baseui/basepageactions"), exports);
|
|
19
23
|
__exportStar(require("./baseui/basepagewaits"), exports);
|
|
@@ -25,5 +29,6 @@ __exportStar(require("./utils/Utils"), exports);
|
|
|
25
29
|
__exportStar(require("./baseapi/baseapihelpers"), exports);
|
|
26
30
|
__exportStar(require("./baseapi/apiutils"), exports);
|
|
27
31
|
__exportStar(require("./constants/test-tags"), exports);
|
|
28
|
-
|
|
32
|
+
var testrail_reporter_1 = require("./reporters/testrail-reporter");
|
|
33
|
+
Object.defineProperty(exports, "TestRailReporter", { enumerable: true, get: function () { return __importDefault(testrail_reporter_1).default; } });
|
|
29
34
|
__exportStar(require("./utils/testrail/client"), exports);
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Reporter, FullConfig, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
export interface TestRailReporterOptions {
|
|
3
|
+
host: string;
|
|
4
|
+
user: string;
|
|
5
|
+
token: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
suiteId: number;
|
|
8
|
+
runName?: string;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
}
|
|
2
11
|
declare class TestRailReporter implements Reporter {
|
|
3
12
|
private client;
|
|
4
13
|
private runId;
|
|
5
14
|
private suiteId;
|
|
6
15
|
private enabled;
|
|
7
|
-
|
|
16
|
+
private runName?;
|
|
17
|
+
constructor(options?: TestRailReporterOptions);
|
|
8
18
|
onBegin(config: FullConfig, suite: Suite): Promise<void>;
|
|
9
19
|
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
10
20
|
}
|
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const client_1 = require("@/utils/testrail/client");
|
|
7
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
-
dotenv_1.default.config();
|
|
9
4
|
class TestRailReporter {
|
|
10
5
|
client = null;
|
|
11
6
|
runId = null;
|
|
12
7
|
suiteId = null;
|
|
13
8
|
enabled = false;
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
runName;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
const isEnabled = options?.enabled ?? process.env.TESTRAIL_REPORTER_ENABLED === 'true';
|
|
12
|
+
if (isEnabled) {
|
|
16
13
|
this.enabled = true;
|
|
17
14
|
try {
|
|
18
|
-
const host = process.env.TESTRAIL_HOST;
|
|
19
|
-
const user = process.env.TESTRAIL_USER;
|
|
20
|
-
const token = process.env.TESTRAIL_PASSWORD;
|
|
21
|
-
const projectId = process.env.TESTRAIL_PROJECT_ID;
|
|
15
|
+
const host = options?.host ?? process.env.TESTRAIL_HOST;
|
|
16
|
+
const user = options?.user ?? process.env.TESTRAIL_USER;
|
|
17
|
+
const token = options?.token ?? process.env.TESTRAIL_PASSWORD;
|
|
18
|
+
const projectId = options?.projectId ?? process.env.TESTRAIL_PROJECT_ID;
|
|
22
19
|
if (!host || !user || !token || !projectId) {
|
|
23
|
-
throw new Error('TestRail credentials are not fully set in environment variables.');
|
|
20
|
+
throw new Error('TestRail credentials are not fully set in options or environment variables.');
|
|
24
21
|
}
|
|
25
22
|
this.client = new client_1.TestRailClient(host, user, token, projectId);
|
|
26
|
-
const suiteIdEnv = process.env.TESTRAIL_SUITE_ID;
|
|
23
|
+
const suiteIdEnv = options?.suiteId?.toString() ?? process.env.TESTRAIL_SUITE_ID;
|
|
27
24
|
if (!suiteIdEnv) {
|
|
28
|
-
throw new Error('TESTRAIL_SUITE_ID
|
|
25
|
+
throw new Error('TESTRAIL_SUITE_ID is not set in options or environment variables.');
|
|
29
26
|
}
|
|
30
27
|
this.suiteId = parseInt(suiteIdEnv, 10);
|
|
31
28
|
if (isNaN(this.suiteId)) {
|
|
32
29
|
throw new Error('TESTRAIL_SUITE_ID is not a valid number.');
|
|
33
30
|
}
|
|
31
|
+
this.runName = options?.runName;
|
|
34
32
|
}
|
|
35
33
|
catch (error) {
|
|
36
34
|
console.error('Failed to initialize TestRail reporter:', error);
|
|
@@ -38,14 +36,14 @@ class TestRailReporter {
|
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
else {
|
|
41
|
-
console.log("TestRail reporter is disabled. Set TESTRAIL_REPORTER_ENABLED to 'true'
|
|
39
|
+
console.log("TestRail reporter is disabled. Set TESTRAIL_REPORTER_ENABLED to 'true' or provide enabled:true in options.");
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
async onBegin(config, suite) {
|
|
45
43
|
if (!this.enabled || !this.client || !this.suiteId)
|
|
46
44
|
return;
|
|
47
45
|
const timestamp = new Date().toLocaleString();
|
|
48
|
-
const runName = `Automated Test Run - ${timestamp}`;
|
|
46
|
+
const runName = this.runName ?? `Automated Test Run - ${timestamp}`;
|
|
49
47
|
const runDescription = `Playwright test run executed on ${timestamp}`;
|
|
50
48
|
try {
|
|
51
49
|
const run = await this.client.createTestRun(this.suiteId, runName, runDescription);
|
|
@@ -52,7 +52,7 @@ class TestRailClient {
|
|
|
52
52
|
include_all: true,
|
|
53
53
|
};
|
|
54
54
|
const run = await this.apiPost(`add_run/${this.projectId}`, data);
|
|
55
|
-
console.log(`Successfully created Test Run with ID: ${run.id}`);
|
|
55
|
+
console.log(`Successfully created Test Run with ID: ${run.id}. View at: ${run.url}`);
|
|
56
56
|
return run;
|
|
57
57
|
}
|
|
58
58
|
async addResultForCase(runId, caseId, status, comment) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transit-core-taf",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Transit Core Automation Framework",
|
|
5
5
|
"main": "dist/transit-core-taf/index.js",
|
|
6
6
|
"types": "dist/transit-core-taf/index.d.ts",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"@types/node": "^24.3.1",
|
|
15
15
|
"@types/pixelmatch": "^5.2.6",
|
|
16
16
|
"@types/pngjs": "^6.0.5",
|
|
17
|
-
"dotenv": "^16.6.1",
|
|
18
17
|
"npm-run-all": "^4.1.5",
|
|
19
18
|
"ts-node": "^10.9.2",
|
|
20
19
|
"typescript": "^5.0.0",
|