-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const {Client} = require("./client");
const {Worker} = require("./worker");
const {AllureWorker} = require("./allure_worker");
async function reportToXrayWithAllureReport(options) {
let allureWorker = new AllureWorker();
let suites = await allureWorker.generateSuitesFromAllureXml(options.resultsFolder);
let worker = new Worker();
await worker.checkOptions(options);
let requestBody = worker.generateXrayRequestFromAllureJson(suites, options);
const client = new Client(options.host);
if(options.security){
await client.login(options.security.client_id, options.security.client_secret);
}
return await client.sendResultsAsXrayJson(JSON.stringify(requestBody));
}
async function reportToXrayWithJunitReport(options) {
let worker = new Worker();
await worker.checkOptions(options);
let requestBody = worker.generateXmlRequestBody(options.resultsFolder, options.fileName);
const client = new Client(options.host);
if(options.security){
await client.login(options.security.client_id, options.security.client_secret);
}
await client.sendResultsAsJunitReport(options.project, options.testPlan, requestBody);
}
module.exports = { reportToXrayWithJunitReport , reportToXrayWithAllureReport};