Skip to content

Added return of HTML file content and option to stop html file creation

Compare
Choose a tag to compare
@lpelypenko lpelypenko released this 13 Sep 04:54
· 31 commits to main since this release

New feature that opens more usages of this library:

From version 2.2.3, createHtmlReport(...) returns HTML content that can be additionally used for specific integrations.

If only HTML content is needed, user can pass doNotCreateReportFile: true to stop report file creation.

Suggestion on how to use this library if you don't need a report file but need only HTML it produces:

const reportHTML = createHtmlReport({
    results: rawAxeResults,
    options: {
        projectKey: 'I need only raw HTML',
        doNotCreateReportFile: true,
    },
});
console.log('reportHTML will have full content of HTML file.');
// suggestion on how to create file by yourself
if (!fs.existsSync('build/reports/saveReportHere.html')) {
    fs.mkdirSync('build/reports', {
        recursive: true,
    });
}
fs.writeFileSync('build/reports/saveReportHere.html', reportHTML);