0

I was able to run my Protractor tests using browserstack-local earlier tonight but was unable to by the end of the evening and I can't figure out what's going on.

node v7.4.0
protractor v5.0.0
browserstack-local v1.2.0

Here's my conf.ts file:

'use strict';

import { Config, browser } from 'protractor';
import testSuites = require('./testSuites.js');
import browserstack = require('browserstack-local');

const commonCapabilities = {
    'browserstack.user': '*****',
    'browserstack.key': '*****',
    'browserstack.local': true
};

export let config: Config = {
    baseUrl: 'https://localhost:8443',

    seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub',

    multiCapabilities: [{
        browserName: 'chrome',
        browser_version: '54.0',
        os: 'Windows',
        os_version: '10',
        resolution: '1280x800'
    }],

    specs: ['src/**/*spec.js'],

    suites: testSuites.suites,

    framework: 'mocha',

    mochaOpts: {
        reporter: 'spec',
        slow: 0,              
        timeout: 60000
    },

    allScriptsTimeout: 3600000,

    onPrepare: () => {
        browser.manage().window().setSize(1280, 800);
    },

    params: {
        user: 'seleniumtesting'
    },

    beforeLaunch() {
        console.log('Starting BrowserStack Local...');
        return new Promise((resolve, reject) => {
            exports.bs_local = new browserstack.Local();
            exports.bs_local.start({ key: commonCapabilities['browserstack.key']}, error => {
                if (error) {
                    return reject(error);
                }

                console.log('BrowserStack Started.');
                resolve();
            });
        });
    },

    afterLaunch() {
        return new Promise(resolve => {
            if (!exports.bs_local) {
                console.log('Skipping shutdown of BrowserStack Local...');
                resolve();
                return;
            }

            console.log('Stopping BrowserStack Local...');
            exports.bs_local.stop(resolve);
        });
    }
};

// Code to support common capabilities
exports.config.multiCapabilities.forEach((caps) => {
    Object.keys(commonCapabilities).forEach(i => {
        caps[i] = caps[i] || commonCapabilities[i];
    });
});

When I run my Protractor tests I'm getting:

Starting BrowserStack Local...
(node:3755) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

/usr/local/lib/node_modules/protractor/node_modules/q/q.js:155
                throw e;
                ^
Error
    at /protractor/node_modules/browserstack-local/lib/Local.js:57:20
    at ChildProcess.exithandler (child_process.js:202:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:501:12)

It's strange because I didn't change anything in my environment since it was last working earlier in the evening, and now I can't get it to run anymore without seeing this error. I've been trying to debug this without any luck, could someone please help me spot if I'm missing anything?

Thanks in advance!

jjelly
  • 73
  • 9
  • 2
    The error points to issues with starting the BrowserStack Local app. I have seen this behaviour if the binary initiated for a previous test run was not terminated correctly. Basically, the binary is already running and the script is trying to initiate it again. You can confirm if the binary is already running by resolving the URL http://localhost:45691/check. If you see "Up and running" then there is a active binary instance. Stop and rerun your tests. If above is not the case then it's better you contact the support team at BrowserStack. Also try contacting support@browserstack.com. – Mukesh Tiwari Feb 08 '17 at 16:27
  • @MukeshTiwari thank you so much for your comment about my scenario. I tried restarting my laptop and running the tests again and things seem to be working again. Your suggestion sounds like it might've been what happened to me but I checked the localhost:45691/check url earlier and it didn't seem to be in use. I know the scenario you speak of, and I recall there being an error message actually telling me that port 45691 is in use.. Anyways, will keep this in mind for next time! – jjelly Feb 08 '17 at 22:29

1 Answers1

0

"os.tmpDir" deprecated onwards Node v7.0.0. Try downgrading your Node and execute.

More details are available in https://github.com/hapijs/hapi/issues/3369

santhosh kumar
  • 1,981
  • 1
  • 9
  • 28