How to launch LambdaTest tunnel for running Mocha.js automation tests?

How to launch LambdaTest tunnel for running Mocha.js automation tests?

Hey Miro!

In order to initiate LambdaTest tunnel to perform Mocha.js testing, you need to follow the below steps -

  1. Download the LambdaTest tunnel binary.

  2. Start LambdaTest tunnel before test case execution. Please check the below code snippet.

     const { exec } = require('child_process');
     describe("Mocha Todo Test " + caps.browserName, function() {
         var driver;
         this.timeout(0);
       
         //execute tunnel binary
         before(function(done) {
             let st = "./LT --user " + LT_USERNAME + " --key "+LT_ACCESS_KEY;
             exec(st, (err, stdout, stderr) => {
                 if (err) {
                   // node couldn't execute the command
                   return;
                 }
               
                 // the *entire* stdout and stderr (buffered)
                 console.log(`stdout: ${stdout}`);
                 console.log(`stderr: ${stderr}`);
               });
         });
         //placeholder, write this function according to your test
         beforeEach(function(done) {done();});
       
         it("testcase", function(done) {
           //execute test case
         });
       
         //placeholder, write this function according to your test
         afterEach(function(done) {done();});
    
       });
    
  3. Set the capability "tunnel": true

Please refer to the below GitHub repo for the same

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