lib/generate-report.js
/**
     * Parse all the scenario steps and enrich them with the correct data
     * @param {object} scenario Preparsed scenario
     * @return {object} A parsed scenario
     * @private
     */
Parse all the scenario steps and enrich them with the correct data
@param {object} scenario Preparsed scenario
@return {object} A parsed scenario
@private
Parse all the scenario steps and enrich them with the correct data @param { object } scenario Preparsed scenario @return { object } A parsed scenario @private
function _parseSteps(scenario) {
        scenario.steps.forEach(step => {
            step.passed = 0
            step.failed = 0
            step.notDefined = 0
            step.skipped = 0
            step.pending = 0
            step.ambiguous = 0
            step.duration = 0
            step.time = '00:00:00.000'
            scenario.isFailed = false
            scenario.isAmbiguous = false
            scenario.isSkipped = false
            scenario.isNotdefined = false
            scenario.isPending = false
            if (step.embeddings !== undefined) {
                const Base64 = require('js-base64').Base64
                step.attachments = []
                step.embeddings.forEach((embedding, embeddingIndex) => {
                    if (embedding.mime_type === 'application/json' || (embedding.media && embedding.media.type === 'application/json')) {
                        step.json = (step.json ? step.json : []).concat([typeof embedding.data === 'string' ? JSON.parse(embedding.data) : embedding.data])
                    } else if (embedding.mime_type === 'text/html' || (embedding.media && embedding.media.type === 'text/html')) {
                        step.html = (step.html ? step.html : []).concat([_isBase64(embedding.data) ? Base64.decode(embedding.data) : embedding.data])
                    } else if (embedding.mime_type === 'text/plain' || (embedding.media && embedding.media.type === 'text/plain')) {
                        step.text = (step.text ? step.text : []).concat([_isBase64(embedding.data) ? _escapeHtml(Base64.decode(embedding.data)) : _escapeHtml(embedding.data)])
                    } else if (embedding.mime_type === 'image/png' || (embedding.media && embedding.media.type === 'image/png')) {
                        step.image = (step.image ? step.image : []).concat(['data:image/png;base64,' + embedding.data])
                        step.embeddings[embeddingIndex] = {}
                    } else {
                        let embeddingtype = 'text/plain'
                        if (embedding.mime_type) {
                            embeddingtype = embedding.mime_type
                        } else if (embedding.media && embedding.media.type) {
                            embeddingtype = embedding.media.type
                        }
                        step.attachments.push({
                            data: 'data:' + embeddingtype + ';base64,' + embedding.data,
                            type: embeddingtype
                        })
                        step.embeddings[embeddingIndex] = {}
                    }
                })
            }
            if (step.doc_string !== undefined) {
                step.restWireData = step.doc_string.value.split(/[>]/).join('').replace(new RegExp('\r?\n', 'g'), '<br />').split('response')
            }
            if (
                !step.result ||
                (step.hidden && !step.text && !step.image && _.size(step.attachments) === 0 && step.result.status !== RESULT_STATUS.failed)
            ) {
                return 0
            }
            if (step.result.duration) {
                scenario.duration += step.result.duration
                step.time = formatDuration(step.result.duration)
            }
            if (step.result.status === RESULT_STATUS.passed) {
                suite.steps.total++
                suite.steps.passed++
                return scenario.passed++
            }
            if (step.result.status === RESULT_STATUS.failed) {
                suite.steps.total++
                suite.steps.failed++
                scenario.isFailed = true
                return scenario.failed++
            }
            if (step.result.status === RESULT_STATUS.notDefined) {
                suite.steps.total++
                suite.steps.notDefined++
                scenario.isNotdefined = true
                return scenario.notDefined++
            }
            if (step.result.status === RESULT_STATUS.pending) {
                suite.steps.total++
                suite.steps.pending++
                scenario.isPending = true
                return scenario.pending++
            }
            if (step.result.status === RESULT_STATUS.ambiguous) {
                suite.steps.total++
                suite.steps.ambiguous++
                scenario.isAmbiguous = true
                return scenario.ambiguous++
            }
            if (step.result.status === RESULT_STATUS.skipped) {
                suite.steps.total++
                suite.steps.skipped++
                scenario.isSkipped = true
                return scenario.skipped++
            }
        })
        return scenario
    }
function _parseSteps ( scenario ) { scenario . steps . forEach ( step => { step . passed = 0 step . failed = 0 step . notDefined = 0 step . skipped = 0 step . pending = 0 step . ambiguous = 0 step . duration = 0 step . time = '00:00:00.000' scenario . isFailed = false scenario . isAmbiguous = false scenario . isSkipped = false scenario . isNotdefined = false scenario . isPending = false if ( step . embeddings !== undefined ) { const Base64 = require ( 'js-base64' ) . Base64 step . attachments = [ ] step . embeddings . forEach ( ( embedding , embeddingIndex ) => { if ( embedding . mime_type === 'application/json' || ( embedding . media && embedding . media . type === 'application/json' ) ) { step . json = ( step . json ? step . json : [ ] ) . concat ( [ typeof embedding . data === 'string' ? JSON . parse ( embedding . data ) : embedding . data ] ) } else if ( embedding . mime_type === 'text/html' || ( embedding . media && embedding . media . type === 'text/html' ) ) { step . html = ( step . html ? step . html : [ ] ) . concat ( [ _isBase64 ( embedding . data ) ? Base64 . decode ( embedding . data ) : embedding . data ] ) } else if ( embedding . mime_type === 'text/plain' || ( embedding . media && embedding . media . type === 'text/plain' ) ) { step . text = ( step . text ? step . text : [ ] ) . concat ( [ _isBase64 ( embedding . data ) ? _escapeHtml ( Base64 . decode ( embedding . data ) ) : _escapeHtml ( embedding . data ) ] ) } else if ( embedding . mime_type === 'image/png' || ( embedding . media && embedding . media . type === 'image/png' ) ) { step . image = ( step . image ? step . image : [ ] ) . concat ( [ 'data:image/png;base64,' + embedding . data ] ) step . embeddings [ embeddingIndex ] = { } } else { let embeddingtype = 'text/plain' if ( embedding . mime_type ) { embeddingtype = embedding . mime_type } else if ( embedding . media && embedding . media . type ) { embeddingtype = embedding . media . type } step . attachments . push ( { data : 'data:' + embeddingtype + ';base64,' + embedding . data , type : embeddingtype } ) step . embeddings [ embeddingIndex ] = { } } } ) } if ( step . doc_string !== undefined ) { step . restWireData = step . doc_string . value . split ( / [>] / ) . join ( '' ) . replace ( new RegExp ( '\r?\n' , 'g' ) , '<br />' ) . split ( 'response' ) } if ( ! step . result || ( step . hidden && ! step . text && ! step . image && _ . size ( step . attachments ) === 0 && step . result . status !== RESULT_STATUS . failed ) ) { return 0 } if ( step . result . duration ) { scenario . duration += step . result . duration step . time = formatDuration ( step . result . duration ) } if ( step . result . status === RESULT_STATUS . passed ) { suite . steps . total ++ suite . steps . passed ++ return scenario . passed ++ } if ( step . result . status === RESULT_STATUS . failed ) { suite . steps . total ++ suite . steps . failed ++ scenario . isFailed = true return scenario . failed ++ } if ( step . result . status === RESULT_STATUS . notDefined ) { suite . steps . total ++ suite . steps . notDefined ++ scenario . isNotdefined = true return scenario . notDefined ++ } if ( step . result . status === RESULT_STATUS . pending ) { suite . steps . total ++ suite . steps . pending ++ scenario . isPending = true return scenario . pending ++ } if ( step . result . status === RESULT_STATUS . ambiguous ) { suite . steps . total ++ suite . steps . ambiguous ++ scenario . isAmbiguous = true return scenario . ambiguous ++ } if ( step . result . status === RESULT_STATUS . skipped ) { suite . steps . total ++ suite . steps . skipped ++ scenario . isSkipped = true return scenario . skipped ++ } } ) return scenario }
Parse all the scenario steps and enrich them with the correct data
 @param {object} scenario Preparsed scenario
 @return {object} A parsed scenario
 @private
Parse all the scenario steps and enrich them with the correct data @param { object } scenario Preparsed scenario @return { object } A parsed scenario @private
/* istanbul ignore else */ // Don't log steps that don't have a text/hidden/images/attachments unless they are failed.
 // This is for the hooks
 //scenario.skipped++;
