How to integrate Jenkins pipeline with Mocha.js on LambdaTest cloud?

How to integrate Jenkins pipeline with Mocha.js on LambdaTest cloud?

Hey Dipen,

To integrate Jenkins pipeline with Mocha.js on LambdaTest cloud, add the below code snippet to your automation scripts.

pipline 
{
    withEnv(["LT_USERNAME=Your LambdaTest UserName",
    "LT_ACCESS_KEY=Your LambdaTest Access Key",
    "LT_TUNNEL=true"]){

    echo env.LT_USERNAME
    echo env.LT_ACCESS_KEY 

    stages{
        stage('setup') { 

            // Get some code from a GitHub repository
            try{
            git 'https://github.com/LambdaTest/mocha-selenium-sample'

            //Download Tunnel Binary
            sh "wget https://s3.amazonaws.com/lambda-tunnel/LT_Linux.zip"

            //Required if unzip is not installed
            sh 'sudo apt-get install --no-act unzip'
            sh 'unzip -o LT_Linux.zip'

            //Starting Tunnel Process 
            sh "./LT -user ${env.LT_USERNAME} -key ${env.LT_ACCESS_KEY} &"
            sh  "rm -rf LT_Linux.zip"
            }
            catch (err){
            echo err
        }

        }
        stage('build') {
            // Installing Dependencies
            sh 'npm i'
            }

        stage('test') {
                try{
                sh 'npm run single'
                }
                catch (err){
                echo err
                }  
        }
        stage('end') {  
            echo "Success" 
            }
        }
    }
}

You can also download and install the given GitHub repo.

https://github.com/rshmimondal/Mocha-js-jenkins