OmbraDiFenice / newman-reporter-confluence

Apache License 2.0
6 stars 2 forks source link

Add handlebars-helpers to count the number of folders, especially folders with failed tests #3

Open DamienChenon opened 4 years ago

DamienChenon commented 4 years ago

At first I would to thanks you for your project. It's very helpful to publish report on confluence with newman. I made the same issuer for newman-reporter-htmlextra project because I use this two project on my continuous integration pipeline.

Is your feature request related to a problem? Please describe. When I made postman collection I organize my tests into folders, but I can't have this indicators in my html report.

Describe the solution you'd like I want to add an handlebars helper to have the number of folders with failed tests If you want I can make a PR, but for now I don't right to create a new branch.

Describe alternatives you've considered I can used the aggregations.length for the sum of my tests, but I can't count the number of folders with failed tests. So I clone your project and I add this handlebars helper and package it to use in my continous integration pipeline.

// Sums the total of folders with failed tests
handlebars.registerHelper('totalFailedFolders', function (aggregations) {
    let failedFolders = 0;
    aggregations.forEach(aggregation => {
        aggregation.executions.forEach(execution => {
            if (execution.cumulativeTests.failed > 0) {
                failedFolders++;
            }
        });
    });
    return failedFolders;
});

Additional context I organize my postman collection with folders because, when I want to test a feature I need to call several API and be sure than my api workflow work fine. For example if I want to test the creation of a customer, I need to test at least 2 call API, the first to create the customer and a second to check I can get this newly customer like I just created.