Skip to content

How to kill sauceConnectProcess #154

@anthonyvialleton

Description

@anthonyvialleton

While running sauce-connect-launcher under a node/jest environment I face some issues.

My environment:

  • node v12.16.2
  • npm 6.14.4
  • jest 25.4.0
  • sauce-connect-launcher 1.3.1
  1. The first problem is:

To be able to setup my tests correctly over jest runtime I wrapped it around a Promise as follow:

const sauceConnectLauncherPromise = new Promise((resolve, reject) => {
    sauceConnectLauncher(sauceConnectOpts, function (err, sauceConnectProcess) {
        if (err) {
            reject(err.message);
            return;
        }
        resolve('Sauce Connect ready');
    });
});

and used like this:

  beforeAll(async () => {
            try {
                // Start Sauce Connect Proxy
                await sauceConnectLauncherPromise;
                ...

This works, but for the connection to be made to Saucelabs I had to remove:

sauceConnectProcess.close(function () {
            console.log("Closed Sauce Connect process");
        });

from sauceConnectLauncher callback. This line causing the tunnel to be aborted when executed...

Is it normal?

  1. sauceConnectLauncher disposes a child process to create the tunnel.
    sauceConnectLauncher callback function embeds sauceConnectProcess but how is it possible to kill this process manually?

I need to kill it for example in an afterAll hook to ensure tests are re-playable

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions