allure-framework / allure-framework/allure3
Single file report generation fails if the test results contain a large number of attachments
- Dominant language
- HTML
- Stars
- 401
- Forks
- 58
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 34
Description
When trying to run the allure generate command the generation fails rue to a RangeError if the test results contains a large number of attachments (i.e. videos)
This is occurs in @allurereport/web-commons/dist/data.js createReportDataScript()
We map the reportFiles and then attempt to .join(',') them, however if the test result contain a large number of video files then the reportFilesDeclaration string can run into the hundreds of millions.
```
export default defineConfig({
name: 'e2e tests',
output: './allure-report-3',
plugins: {
awesome: {
options: {
singleFile: true,
reportLanguage: 'en',
},
},
},
});
```
Example:
```
const mappedReportFilesArray = reportFiles.map(({ name, value }) => `d('${name}','${value}')`);
const { averageLength, longestValue } = analyzeReportFileValues(reportFiles);
console.log(`Average Length: ${averageLength}`);
console.log(`Longest Value: ${longestValue}`);
console.log(`Longest Value Length: ${longestValue.length}`);
const { mean, stdDev, outlierThreshold, outliers } = findSignificantOutliers(reportFiles);
console.log(`Mean length: ${mean}`);
console.log(`Standard deviation: ${stdDev}`);
console.log(`Outlier threshold (values > ${outlierThreshold}):`);
if (outliers.length > 0) {
console.log(`Found ${outliers.length} outliers:`);
outliers.forEach(({ name, value }) => console.log(`Name: ${name}, Length: ${value.length}`));
} else {
console.log('No significant outliers found.');
}
const reportFilesDeclaration = mappedReportFilesArray.join(',');
```
```
function analyzeReportFileValues(reportFiles) {
let totalLength = 0;
let longestValue = '';
// Iterate through the array of objects
for (const { value } of reportFiles) {
const valueLength = value.length;
totalLength += valueLength; // Accumulate the total length
// Check if this value is the longest
if (valueLength > longestValue.length) {
longestValue = value;
}
}
// Calculate the average length
const averageLength = totalLength / reportFiles.length;
return { averageLength, longestValue };
}
function findSignificantOutliers(reportFiles) {
const lengths = reportFiles.map(({ value }) => value.length); // Get lengths of all values
// Calculate mean (average)
const total = lengths.reduce((sum, length) => sum + length, 0); // Sum of lengths
const mean = total / lengths.length;
// Calculate standard deviation
const variance = lengths.reduce((sum, length) => sum + Math.pow(length - mean, 2), 0) / lengths.length;
const stdDev = Math.sqrt(variance);
// Define a threshold for outliers (e.g., 2 standard deviations above the mean)
const outlierThreshold = mean + 2 * stdDev;
// Find outliers
const outliers = reportFiles.filter(({ value }) => value.length > outlierThreshold);
return { mean, stdDev, outlierThreshold, outliers };
}
```
```
Longest Value Length: 6405912
data.js:21Mean length: 480212.32706222864
data.js:22Standard deviation: 1005064.7876301509
data.js:23Outlier threshold (values > 2490341.9023225303):
data.js:26Found 96 outliers:
data.js:27Name: data/attachments/7e4ddd375b1ace75b06cde67cd978302.webm, Length: 2640536
data.js:27Name: data/attachments/14c382769fac3f0e6246f9c0322452ab.webm, Length: 3441452
data.js:27Name: data/attachments/84a7974877890faad9a4b16107c08503.webm, Length: 5161864
data.js:27
etc etc
```
Contributor guide
Research direction
Start in @allurereport/web-commons/dist/data.js at createReportDataScript() and reproduce the failure with allure generate using singleFile and many large attachments. Trace how reportFilesDeclaration is assembled and verify that the reported large-attachment case completes without a RangeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100