browserstack / browserstack-local-nodejs

NodeJS bindings for BrowserStack Local
https://www.browserstack.com
MIT License
71 stars 56 forks source link

exports.bs_local.stop does not stop browserstack-local #43

Closed jpezninjo closed 6 years ago

jpezninjo commented 6 years ago

Hey! So my team is trying to use Browserstack in our CI line. We're using bitbucket pipelines and for some reason it appears that calling exports.bs_local.stop does not stop browserstack-local. Our script works running on our locals, though.

Here's our conf.js `beforeLaunch() { console.log("Connecting local"); return new Promise((resolve, reject) => { exports.bs_local = new browserstack.Local(); exports.bs_local.start({"key": exports.config.capabilities["browserstack.key"]}, ((error) => { if (error) return reject(error); console.log("Connected. Now testing...");

            resolve();
        }));
    });
},

// Code to stop browserstack local after end of test
afterLaunch() {
    console.log("Got to end promise");
    return new Promise((resolve, reject) => {
        console.log("Inside end promise");
        // stop the Local instance
        exports.bs_local.stop(function() {
          console.log("Stopped BrowserStackLocal");
        });
    });
}`

Logs show that "Got to end promise" and "Inside end promise" get printed but not "Stopped BrowserStackLocal"

I'm just an intern. Please don't shoot me if I'm using exports wrong

punitx commented 6 years ago

Hey @jpezninjo, this is a known issue of BrowserStackLocal with BitBucket pipeline. Please refer: https://github.com/browserstack/browserstack-local-nodejs/issues/25.

We are actively working on a fix and will let you know. As a workaround for now, can you please try killing it manually via process.kill(exports.bs_local.pid) and let me know if that resolves your issue for now.

Also, no one is going shoot anyone, intern, or not. So don't worry about that. 😃

jpezninjo commented 6 years ago

Hey @punitx, that works! Thank you so much. My team is going to be so glad haha. Also I've never raised a Github issue before, so thanks for being so kind!

jpezninjo commented 6 years ago

hey @punitx , I was wondering if you know how to make the browserstack local process exit with fail if any of the tests failed?

punitx commented 6 years ago

Hey @jpezninjo, I am not sure why would you want the BrowserStack Local process to exit (with fail) if any of the tests failed. I think that you actually want to mark your tests as failed. If that's the case, then please refer this otherwise please share your use case here so that I can help further.

jpezninjo commented 6 years ago

I'd want the process to return a fail code (sorry if my jargon is off) in our pipeline that handles deployment of our app. So if any of our protractor tests fail, we don't continue in the pipeline and halt before deployment.

Please confirm my understanding, if I use that PUT with a status:"failed", will I get what I'm looking for? Also how do I attach that request to fails?

punitx commented 6 years ago

I think protractor tests automatically mark tests as failed if any of the assertions fail. You will just need to add proper assertions in your test suite. After that, you just need to capture the exit code of your protractor command and act accordingly. That should serve your requirement.

Also, can you please point your queries to support@browserstack.com. They will gladly help you further.