Search code examples
typescriptjenkinscucumbercypressallure

How to configure Allure report generation for pending test cases in a Cypress/Cucumber/Typescript project with Jenkins?


I am using Cypress, Cucumber with Typescript project. So far Allure report is generate sucessfuly when we have pass/failed test cases only. But report not generated(Show NaN, allure-results folder does not exist)when I used Cucumber tags, which create some test cases in pending status. Test run in Jenkins/Docker environment, here is my pipeline scripts.

pipeline {
  agent {
    kubernetes {
        yaml """
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: cypress
    image: cypress/included:12.10.0
    command:
    - cat
    tty: true
  - name: git
    image: alpine/git
    command:
    - cat
    tty: true
  securityContext:
    runAsUser: 1000
    runAsGroup: 3000
    fsGroup: 2000    
  """
    }
  }

  options {
    timeout(time: 60, unit: 'MINUTES')
    buildDiscarder(logRotator(numToKeepStr: '10'))
  }

  stages {
    stage('Clone repository') {
      steps {
        container('git') {
            git(
               url: 'tests/explorer.git',
               credentialsId: 'tests-explorer',
               branch: 'dev'
            )
        }
      }
    }
    stage('Cypress') {
      steps {
        container('cypress') {
          dir('ui-auto-tests') {
           sh '''
            CYPRESS_CACHE_FOLDER=/tmp/.cypress-cache \\
            npm install
            ./node_modules/.bin/cypress install --force
            '''
            sh '''
            NO_COLOR=1 \\
            CYPRESS_CACHE_FOLDER=/tmp/.cypress-cache \\
            npx cypress run --browser chrome --env allure=true
            '''
          }
        }
      }
    }
  } 
  
   post {
          always {
            script {
              allure([
                includeProperties: false,
                jdk: '',
                properties: [],
                reportBuildPolicy: 'ALWAYS',
                results: [[path: 'ui-auto-tests/allure-results']]
              ])
            }
          }
          success {
              slackSend channel: 'reporting-qa', color: '#00FF00',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Success\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
          failure {
              slackSend channel: 'reporting-qa', color: 'FF0000',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Failed\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
          aborted {
              slackSend channel: 'reporting-qa', color: '808080',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Pending\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
    }
}

I tried with all the status. for pending test cases status are always, changed, fixed, regression, aborted, success, unsuccessful, unstable, failure, notBuilt, cleanup


Solution

  • Above script, I want to run following query

    npx cypress run --browser chrome --env allure=true --env TAGS='"@Smoke"'
    

    not

    npx cypress run --browser chrome --env allure=true
    

    So issue was fixed, when I updated above query as following

    npx cypress run --browser chrome --env allure=true, TAGS='"@Smoke"'