View in #general on Slack
@peter.nguyentr: anyone knows how to enable local testing for BS config?
@lukoyanov94:
const browserstack = require("browserstack-local");
// to avoid same names in simultaneous launch for multiple runner
const _localIdentifier = `local_${Date.now()}_${Math.random().toString(36).substring(7)}`;
// take credentials from environment variables
const _user = process.env.BS_CREDS_USR;
const _key = process.env.BS_CREDS_PSW;
exports.config = {
...
bootstrap: function(done) {
if (_user && _key) {
console.log(`Connecting local. Identifier: "${_localIdentifier}"`);
module.exports.bs_local = new browserstack.Local();
module.exports.bs_local.start(
{
onlyAutomate: true,
key: _key,
localIdentifier: _localIdentifier
},
function(error) {
if (error) {
console.log(error);
return error;
}
console.log("Connected. Now testing...");
done();
}
);
} else done();
},
teardown: function(done) {
if (_user && _key) {
module.exports.bs_local.stop(() => {
console.log("Disconnected");
done();
});
} else done();
},
...
}
@peter.nguyentr: thanks so much,