transit-core-taf 1.0.10 → 1.0.12
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 +3 -6
- package/dist/transit-core-taf/reporters/testrail-reporter.d.ts +2 -1
- package/dist/transit-core-taf/reporters/testrail-reporter.js +5 -4
- package/dist/transit-core-taf/utils/testrail/client.d.ts +9 -7
- package/dist/transit-core-taf/utils/testrail/client.js +15 -17
- package/dist/transit-core-taf/utils/testrail-importer.d.ts +15 -0
- package/dist/transit-core-taf/utils/testrail-importer.js +64 -0
- package/package.json +1 -1
|
@@ -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 { default as TestRailReporter, TestRailReporterOptions } from './reporters/testrail-reporter';
|
|
13
12
|
export * from './utils/testrail/client';
|
|
13
|
+
export { uploadJunitToTestRail, TestRailJunitImporterOptions } from './utils/testrail-importer';
|
|
@@ -13,11 +13,8 @@ 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
|
-
};
|
|
19
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
17
|
+
exports.uploadJunitToTestRail = void 0;
|
|
21
18
|
__exportStar(require("./baseui/basepagevalidations"), exports);
|
|
22
19
|
__exportStar(require("./baseui/basepageactions"), exports);
|
|
23
20
|
__exportStar(require("./baseui/basepagewaits"), exports);
|
|
@@ -29,6 +26,6 @@ __exportStar(require("./utils/Utils"), exports);
|
|
|
29
26
|
__exportStar(require("./baseapi/baseapihelpers"), exports);
|
|
30
27
|
__exportStar(require("./baseapi/apiutils"), exports);
|
|
31
28
|
__exportStar(require("./constants/test-tags"), exports);
|
|
32
|
-
var testrail_reporter_1 = require("./reporters/testrail-reporter");
|
|
33
|
-
Object.defineProperty(exports, "TestRailReporter", { enumerable: true, get: function () { return __importDefault(testrail_reporter_1).default; } });
|
|
34
29
|
__exportStar(require("./utils/testrail/client"), exports);
|
|
30
|
+
var testrail_importer_1 = require("./utils/testrail-importer");
|
|
31
|
+
Object.defineProperty(exports, "uploadJunitToTestRail", { enumerable: true, get: function () { return testrail_importer_1.uploadJunitToTestRail; } });
|
|
@@ -2,7 +2,8 @@ import { Reporter, FullConfig, Suite, TestCase, TestResult } from '@playwright/t
|
|
|
2
2
|
export interface TestRailReporterOptions {
|
|
3
3
|
host: string;
|
|
4
4
|
user: string;
|
|
5
|
-
token
|
|
5
|
+
token?: string;
|
|
6
|
+
password?: string;
|
|
6
7
|
projectId: string;
|
|
7
8
|
suiteId: number;
|
|
8
9
|
runName?: string;
|
|
@@ -14,12 +14,13 @@ class TestRailReporter {
|
|
|
14
14
|
try {
|
|
15
15
|
const host = options?.host ?? process.env.TESTRAIL_HOST;
|
|
16
16
|
const user = options?.user ?? process.env.TESTRAIL_USER;
|
|
17
|
-
const token = options?.token ?? process.env.
|
|
17
|
+
const token = options?.token ?? process.env.TESTRAIL_TOKEN;
|
|
18
|
+
const password = options?.password ?? process.env.TESTRAIL_PASSWORD;
|
|
18
19
|
const projectId = options?.projectId ?? process.env.TESTRAIL_PROJECT_ID;
|
|
19
|
-
if (!host || !user || !token || !projectId) {
|
|
20
|
-
throw new Error('TestRail credentials are not fully set in options or environment variables.');
|
|
20
|
+
if (!host || !user || !(token || password) || !projectId) {
|
|
21
|
+
throw new Error('TestRail credentials (host, user, projectId, and token/password) are not fully set in options or environment variables.');
|
|
21
22
|
}
|
|
22
|
-
this.client = new client_1.TestRailClient(host, user, token,
|
|
23
|
+
this.client = new client_1.TestRailClient({ host, user, projectId, token, password });
|
|
23
24
|
const suiteIdEnv = options?.suiteId?.toString() ?? process.env.TESTRAIL_SUITE_ID;
|
|
24
25
|
if (!suiteIdEnv) {
|
|
25
26
|
throw new Error('TESTRAIL_SUITE_ID is not set in options or environment variables.');
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface TestRailClientOptions {
|
|
2
|
+
host: string;
|
|
3
|
+
user: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
token?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
}
|
|
4
8
|
export declare class TestRailClient {
|
|
5
9
|
private host;
|
|
6
10
|
private user;
|
|
7
|
-
private token;
|
|
8
11
|
private projectId;
|
|
9
12
|
private auth;
|
|
10
|
-
constructor(
|
|
13
|
+
constructor(options: TestRailClientOptions);
|
|
11
14
|
private apiPost;
|
|
12
15
|
createTestRun(suiteId: number, name: string, description: string): Promise<any>;
|
|
13
|
-
|
|
16
|
+
loadJunitReport(runId: number, xmlContent: string): Promise<any>;
|
|
14
17
|
}
|
|
15
|
-
export {};
|
|
@@ -14,18 +14,18 @@ const statusMap = {
|
|
|
14
14
|
class TestRailClient {
|
|
15
15
|
host;
|
|
16
16
|
user;
|
|
17
|
-
token;
|
|
18
17
|
projectId;
|
|
19
18
|
auth;
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
constructor(options) {
|
|
20
|
+
const { host, user, projectId, token, password } = options;
|
|
21
|
+
if (!host || !user || !projectId || !(token || password)) {
|
|
22
|
+
throw new Error('TestRail host, user, project ID, and a token or password are required.');
|
|
23
23
|
}
|
|
24
24
|
this.host = host;
|
|
25
25
|
this.user = user;
|
|
26
|
-
this.token = token;
|
|
27
26
|
this.projectId = projectId;
|
|
28
|
-
|
|
27
|
+
const credentials = token ?? password;
|
|
28
|
+
this.auth = `Basic ${Buffer.from(`${this.user}:${credentials}`).toString('base64')}`;
|
|
29
29
|
}
|
|
30
30
|
async apiPost(endpoint, data) {
|
|
31
31
|
const url = `${this.host}index.php?/api/v2/${endpoint}`;
|
|
@@ -55,17 +55,15 @@ class TestRailClient {
|
|
|
55
55
|
console.log(`Successfully created Test Run with ID: ${run.id}. View at: ${run.url}`);
|
|
56
56
|
return run;
|
|
57
57
|
}
|
|
58
|
-
async
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return this.apiPost(`add_result_for_case/${runId}/${caseId}`, data);
|
|
58
|
+
async loadJunitReport(runId, xmlContent) {
|
|
59
|
+
console.log(`Uploading JUnit report to TestRail for run ID: ${runId}...`);
|
|
60
|
+
const base64Content = Buffer.from(xmlContent).toString('base64');
|
|
61
|
+
const data = {
|
|
62
|
+
junit_report: base64Content,
|
|
63
|
+
};
|
|
64
|
+
const result = await this.apiPost(`load_junit/${runId}`, data);
|
|
65
|
+
console.log(`Successfully uploaded JUnit report to TestRail.`);
|
|
66
|
+
return result;
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
exports.TestRailClient = TestRailClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TestRailClientOptions } from './testrail/client';
|
|
2
|
+
export interface TestRailJunitImporterOptions extends TestRailClientOptions {
|
|
3
|
+
runId: number;
|
|
4
|
+
junitPath: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Uploads a JUnit XML report to a specified TestRail test run.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: For this to work correctly, your test names must include the TestRail Case ID.
|
|
10
|
+
* The TestRail JUnit parser uses the test name to map results to cases.
|
|
11
|
+
* Example: test('C12345 My test description', async ({ page }) => { ... });
|
|
12
|
+
*
|
|
13
|
+
* @param options - The configuration options for the TestRail client and the JUnit import.
|
|
14
|
+
*/
|
|
15
|
+
export declare function uploadJunitToTestRail(options: TestRailJunitImporterOptions): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.uploadJunitToTestRail = uploadJunitToTestRail;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const client_1 = require("./testrail/client");
|
|
39
|
+
/**
|
|
40
|
+
* Uploads a JUnit XML report to a specified TestRail test run.
|
|
41
|
+
*
|
|
42
|
+
* IMPORTANT: For this to work correctly, your test names must include the TestRail Case ID.
|
|
43
|
+
* The TestRail JUnit parser uses the test name to map results to cases.
|
|
44
|
+
* Example: test('C12345 My test description', async ({ page }) => { ... });
|
|
45
|
+
*
|
|
46
|
+
* @param options - The configuration options for the TestRail client and the JUnit import.
|
|
47
|
+
*/
|
|
48
|
+
async function uploadJunitToTestRail(options) {
|
|
49
|
+
const { host, user, projectId, token, password, runId, junitPath } = options;
|
|
50
|
+
if (!fs.existsSync(junitPath)) {
|
|
51
|
+
throw new Error(`JUnit report not found at path: ${junitPath}`);
|
|
52
|
+
}
|
|
53
|
+
const client = new client_1.TestRailClient({ host, user, projectId, token, password });
|
|
54
|
+
try {
|
|
55
|
+
console.log(`Reading JUnit report from: ${junitPath}`);
|
|
56
|
+
const xmlContent = fs.readFileSync(junitPath, 'utf-8');
|
|
57
|
+
await client.loadJunitReport(runId, xmlContent);
|
|
58
|
+
console.log('Successfully completed JUnit report upload to TestRail.');
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('Failed to upload JUnit report to TestRail.', error);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|