-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6b04a9
commit e5c7d57
Showing
4 changed files
with
143 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export function extractData(resultPath, testType, buildNumber=process.argv[2]) { | ||
const files = fs.readdirSync(resultPath); | ||
const totalTestRun = files.filter((file) => file.endsWith('.json')).length; | ||
|
||
let passedCount = 0; | ||
let failedCount = 0; | ||
|
||
const baseUrl = 'https://instatruck.github.io/instatruck-driver-app' | ||
let uri; | ||
|
||
files | ||
.filter((file) => file.endsWith('.json')) | ||
.map((file) => { | ||
const filePath = path.join(resultPath, file); | ||
const fileContent = fs.readFileSync(filePath, 'utf-8'); | ||
const jsonData = JSON.parse(fileContent); | ||
|
||
if (jsonData.status === 'passed') { | ||
passedCount++; | ||
} else if (jsonData.status === 'failed') { | ||
failedCount++; | ||
} | ||
}); | ||
|
||
|
||
if (testType === 'Unit Test') { | ||
uri = "allure-history-ut"; | ||
} | ||
else if (testType === 'Android Test') { | ||
uri = "allure-history-android"; | ||
} | ||
else { | ||
uri = "allure-history-ios"; | ||
} | ||
|
||
return { | ||
testType: testType, | ||
totalTestCases: totalTestRun, | ||
totalPass: passedCount, | ||
totalFail: failedCount, | ||
reportLink: `${baseUrl}/${uri}/${buildNumber}` | ||
}; | ||
} | ||
|
||
|
||
let data = [ | ||
extractData('allure-results-ut', 'Unit Test'), | ||
extractData('allure-results-detox', 'Android Test'), | ||
extractData('allure-results-detox', 'iOS Test'), | ||
]; | ||
|
||
const jsonData = JSON.stringify(data, null, 2); | ||
fs.writeFileSync('report.json', jsonData, 'utf-8'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Test Report</title> | ||
<style> | ||
table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
} | ||
|
||
th, | ||
td { | ||
border: 1px solid black; | ||
padding: 10px; | ||
text-align: center; | ||
} | ||
|
||
th { | ||
background-color: #f2f2f2; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Driver App Test Report</h1> | ||
<table id="testTable"> | ||
<tr> | ||
<th>Test Type</th> | ||
<th>Total Test Cases</th> | ||
<th>Total Passed</th> | ||
<th>Total Failed</th> | ||
<th>Report Link</th> | ||
</tr> | ||
</table> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable prettier/prettier */ | ||
|
||
fetch('report.json') | ||
.then(response => response.json()) | ||
.then(data => { | ||
// Populate the table with dynamic data | ||
const table = document.getElementById('testTable'); | ||
|
||
data.forEach(testType => { | ||
const row = table.insertRow(); | ||
const columns = ['testType', 'totalTestCases', 'totalPass', 'totalFail', 'reportLink']; | ||
|
||
columns.forEach(column => { | ||
const cell = row.insertCell(); | ||
if (column === 'reportLink') { | ||
cell.innerHTML = `<a href="${testType[column]}">View Report</a>`; | ||
} else { | ||
cell.textContent = testType[column]; | ||
} | ||
}); | ||
}); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching test data:', error); | ||
}); |