Skip to content

Commit

Permalink
fix(stepByStepReport): no records html is generated when running with…
Browse files Browse the repository at this point in the history
… run-workers
  • Loading branch information
kobenguyent committed Dec 13, 2024
1 parent f7dae22 commit 5afeb3b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/plugin/stepByStepReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,39 +141,39 @@ module.exports = function (config) {
await recorder.add(() => {
const recordedTests = getRecordFoldersWithDetails(reportDir)
generateRecordsHtml(recordedTests)
});
});
})
})

function getRecordFoldersWithDetails(dirPath) {
let results = {};
let results = {}

try {
const items = fs.readdirSync(dirPath, { withFileTypes: true });
const items = fs.readdirSync(dirPath, { withFileTypes: true })

items.forEach(item => {
items.forEach((item) => {
if (item.isDirectory() && item.name.startsWith('record_')) {
const recordFolderPath = path.join(dirPath, item.name);
const indexPath = path.join(recordFolderPath, 'index.html');
const recordFolderPath = path.join(dirPath, item.name)
const indexPath = path.join(recordFolderPath, 'index.html')

let name = '';
let name = ''
if (fs.existsSync(indexPath)) {
try {
const htmlContent = fs.readFileSync(indexPath, 'utf-8');
const $ = cheerio.load(htmlContent);
name = $('.navbar-brand').text().trim();
const htmlContent = fs.readFileSync(indexPath, 'utf-8')
const $ = cheerio.load(htmlContent)
name = $('.navbar-brand').text().trim()
} catch (err) {
console.error(`Error reading index.html in ${recordFolderPath}:`, err.message);
console.error(`Error reading index.html in ${recordFolderPath}:`, err.message)
}
}

results[name || 'Unkown'] = `${item.name}/index.html`
}
});
})
} catch (err) {
console.error(`Error reading directory ${dirPath}:`, err.message);
console.error(`Error reading directory ${dirPath}:`, err.message)
}

return results;
return results
}

function generateRecordsHtml(recordedTests) {
Expand Down

0 comments on commit 5afeb3b

Please sign in to comment.