Skip to content

Instantly share code, notes, and snippets.

@Xotabu4
Created March 31, 2021 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xotabu4/fc066ef32ce50bb6c9013e02cb5375b8 to your computer and use it in GitHub Desktop.
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
/**
* @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