Created
March 31, 2021 11:51
-
-
Save Xotabu4/fc066ef32ce50bb6c9013e02cb5375b8 to your computer and use it in GitHub Desktop.
Upload results to awesome https://github.com/kochetkov-ma/allure-server and generate report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @url https://github.com/kochetkov-ma/allure-server | |
*/ | |
const got = require('got') | |
const fs = require('fs'); | |
const FormData = require('form-data'); | |
const baseUrl = new URL(`http://93.126.97.71:5001`) | |
const baseGot = got.extend({ | |
prefixUrl: baseUrl, | |
responseType: 'json' | |
}); | |
async function uploadAndGenerate() { | |
const form = new FormData(); | |
form.append('allureResults', fs.createReadStream('./allure-results.zip')); | |
const resultsResp = await baseGot('api/result', { | |
method: 'POST', | |
body: form, | |
}) | |
console.log(`Upload done: `, resultsResp.body) | |
const results_id = resultsResp.body.uuid | |
const reportUrl = await baseGot('api/report', { | |
method: 'POST', | |
json: { | |
"reportSpec": { | |
"path": [ | |
"10-js-ui-wdio" | |
] | |
}, | |
"results": [ | |
results_id | |
], | |
"deleteResults": true | |
} | |
}) | |
console.log(`Report generation done: `, reportUrl.body) | |
console.log(`========================================================================`) | |
console.log(`REPORT URL: `, reportUrl.body.url) | |
console.log(`========================================================================`) | |
} | |
uploadAndGenerate().catch(err => { | |
throw err | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment