lib/html_formatter.js
function generateHTML(testResults) {
        var stepsHtml = '',
            header = '',
            isPassed = false,
            passedScenarios = 0,
            passedSteps = 0,
            stepsNumber = 0,
            scenariosNumber = 0,
            scenariosNumberInFeature = 0,
            passedScenariosNumberInFeature = 0,
            stepsNumberInFeature = 0,
            passedStepsInFeature = 0,
            scenariosHtml = '',
            element,
            step,
            stepDuration = 0;

        html = '';
        for (var i = 0; i < testResults.length; i++) {

            scenariosNumberInFeature = 0;
            passedScenariosNumberInFeature = 0;
            stepsNumberInFeature = 0;
            passedStepsInFeature = 0;
            scenariosHtml = '';
            if (testResults[i].elements) {
                for (var j = 0; j < testResults[i].elements.length; j++) {
                    element = testResults[i].elements[j];
                    if (element.type === 'scenario') {
                        scenariosNumber++;
                        scenariosNumberInFeature++;
                        stepsHtml = '';
                        isPassed = true;
                        for (var k = 0; k < testResults[i].elements[j].steps.length; k++) {
                            step = testResults[i].elements[j].steps[k];

                            if (isEmptyAfterStep(step) || isEmptyBeforeStep(step)) {
                                continue;
                            }

                            if (isAfterStepWithScreenshot(step)) {
                                stepsHtml += getAfterScreenshotStep(step);
                            } else {
                                stepsHtml += getStep(step);
                                stepDuration += (step.result.duration ? step.result.duration : 0);
                                stepsNumber++;
                                stepsNumberInFeature++;
                                if (step.result.status !== statuses.PASSED) {
                                    isPassed = false;
                                } else if (step.result.status === statuses.PASSED) {
                                    passedSteps++;
                                    passedStepsInFeature++;
                                }
                            }
                        }

                        if (isPassed) {
                            passedScenarios++;
                            passedScenariosNumberInFeature++;
                        }
                        scenariosHtml += getScenarioContainer(getScenario(element, isPassed, stepsHtml));
                    }
                }
            }
            html += getFeatureWithScenarios(getFeature(testResults[i], scenariosNumberInFeature, passedScenariosNumberInFeature, stepsNumberInFeature, passedStepsInFeature) + scenariosHtml);
        }
        header = getHeader(scenariosNumber, passedScenarios, stepsNumber, passedSteps, calculateDuration(stepDuration));
        return header + html;
    }
function generateHTML(testResults) {
        var stepsHtml = '',
            header = '',
            isPassed = false,
            passedScenarios = 0,
            passedSteps = 0,
            stepsNumber = 0,
            scenariosNumber = 0,
            scenariosNumberInFeature = 0,
            passedScenariosNumberInFeature = 0,
            stepsNumberInFeature = 0,
            passedStepsInFeature = 0,
            scenariosHtml = '',
            element,
            step,
            stepDuration = 0;

        html = '';
        for (var i = 0; i < testResults.length; i++) {

            scenariosNumberInFeature = 0;
            passedScenariosNumberInFeature = 0;
            stepsNumberInFeature = 0;
            passedStepsInFeature = 0;
            scenariosHtml = '';
            if (testResults[i].elements) {
                for (var j = 0; j < testResults[i].elements.length; j++) {
                    element = testResults[i].elements[j];
                    if (element.type === 'scenario') {
                        scenariosNumber++;
                        scenariosNumberInFeature++;
                        stepsHtml = '';
                        isPassed = true;
                        for (var k = 0; k < testResults[i].elements[j].steps.length; k++) {
                            step = testResults[i].elements[j].steps[k];

                            if (isEmptyAfterStep(step) || isEmptyBeforeStep(step)) {
                                continue;
                            }

                            if (isAfterStepWithScreenshot(step)) {
                                stepsHtml += getAfterScreenshotStep(step);
                            } else {
                                stepsHtml += getStep(step);
                                stepDuration += (step.result.duration ? step.result.duration : 0);
                                stepsNumber++;
                                stepsNumberInFeature++;
                                if (step.result.status !== statuses.PASSED) {
                                    isPassed = false;
                                } else if (step.result.status === statuses.PASSED) {
                                    passedSteps++;
                                    passedStepsInFeature++;
                                }
                            }
                        }

                        if (isPassed) {
                            passedScenarios++;
                            passedScenariosNumberInFeature++;
                        }
                        scenariosHtml += getScenarioContainer(getScenario(element, isPassed, stepsHtml));
                    }
                }
            }
            html += getFeatureWithScenarios(getFeature(testResults[i], scenariosNumberInFeature, passedScenariosNumberInFeature, stepsNumberInFeature, passedStepsInFeature) + scenariosHtml);
        }
        header = getHeader(scenariosNumber, passedScenarios, stepsNumber, passedSteps, calculateDuration(stepDuration));
        return header + html;
    }
function generateHTML ( testResults ) { var stepsHtml = '' , header = '' , isPassed = false , passedScenarios = 0 , passedSteps = 0 , stepsNumber = 0 , scenariosNumber = 0 , scenariosNumberInFeature = 0 , passedScenariosNumberInFeature = 0 , stepsNumberInFeature = 0 , passedStepsInFeature = 0 , scenariosHtml = '' , element , step , stepDuration = 0 ; html = '' ; for ( var i = 0 ; i < testResults . length ; i ++ ) { scenariosNumberInFeature = 0 ; passedScenariosNumberInFeature = 0 ; stepsNumberInFeature = 0 ; passedStepsInFeature = 0 ; scenariosHtml = '' ; if ( testResults [ i ] . elements ) { for ( var j = 0 ; j < testResults [ i ] . elements . length ; j ++ ) { element = testResults [ i ] . elements [ j ] ; if ( element . type === 'scenario' ) { scenariosNumber ++ ; scenariosNumberInFeature ++ ; stepsHtml = '' ; isPassed = true ; for ( var k = 0 ; k < testResults [ i ] . elements [ j ] . steps . length ; k ++ ) { step = testResults [ i ] . elements [ j ] . steps [ k ] ; if ( isEmptyAfterStep ( step ) || isEmptyBeforeStep ( step ) ) { continue ; } if ( isAfterStepWithScreenshot ( step ) ) { stepsHtml += getAfterScreenshotStep ( step ) ; } else { stepsHtml += getStep ( step ) ; stepDuration += ( step . result . duration ? step . result . duration : 0 ) ; stepsNumber ++ ; stepsNumberInFeature ++ ; if ( step . result . status !== statuses . PASSED ) { isPassed = false ; } else if ( step . result . status === statuses . PASSED ) { passedSteps ++ ; passedStepsInFeature ++ ; } } } if ( isPassed ) { passedScenarios ++ ; passedScenariosNumberInFeature ++ ; } scenariosHtml += getScenarioContainer ( getScenario ( element , isPassed , stepsHtml ) ) ; } } } html += getFeatureWithScenarios ( getFeature ( testResults [ i ] , scenariosNumberInFeature , passedScenariosNumberInFeature , stepsNumberInFeature , passedStepsInFeature ) + scenariosHtml ) ; } header = getHeader ( scenariosNumber , passedScenarios , stepsNumber , passedSteps , calculateDuration ( stepDuration ) ) ; return header + html ; }
Generate html code which contains all elements needed to generate reports
@param testResults
@returns {string}
Generate html code which contains all elements needed to generate reports