Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browserstack-cypress-cli

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserstack-cypress-cli - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

bin/commands/info.js

@@ -10,3 +10,3 @@ 'use strict';

module.exports = function info(args) {
let bsConfigPath = process.cwd() + args.cf;
let bsConfigPath = utils.getConfigPath(args.cf);

@@ -13,0 +13,0 @@ return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {

@@ -5,7 +5,9 @@ 'use strict';

logger = require("../helpers/logger").winstonLogger,
utils = require("../helpers/utils");
utils = require("../helpers/utils"),
util = require("util"),
path = require('path');
module.exports = function init(args) {
if (args.p) {
var path_to_bsconf = args.p + "/browserstack.json";
var path_to_bsconf = path.join(args.p + "/browserstack.json");
} else {

@@ -20,17 +22,19 @@ var path_to_bsconf = "./browserstack.json";

function allDone() {
let message = Constants.userMessages.CONFIG_FILE_CREATED
logger.info(message);
utils.sendUsageReport(null, args, message, Constants.messageTypes.SUCCESS, null);
}
return fileHelpers.fileExists(config.path, function(exists){
if (exists) {
let message = Constants.userMessages.CONFIG_FILE_EXISTS;
return fileHelpers.dirExists(config.path, function(dirExists){
if (dirExists) {
fileHelpers.fileExists(config.path, function(exists){
if (exists) {
let message = Constants.userMessages.CONFIG_FILE_EXISTS;
logger.error(message);
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'bstack_json_already_exists');
} else {
fileHelpers.write(config, null, args, utils.configCreated);
}
});
} else {
let message = util.format(Constants.userMessages.DIR_NOT_FOUND, path.dirname(config.path));
logger.error(message);
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'bstack_json_already_exists');
} else {
fileHelpers.write(config, null, allDone);
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'path_to_init_not_found');
}
});
}

@@ -13,3 +13,3 @@ 'use strict';

module.exports = function run(args) {
let bsConfigPath = process.cwd() + args.cf;
let bsConfigPath = utils.getConfigPath(args.cf);

@@ -42,5 +42,8 @@ return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {

// Create build
return build.createBuild(bsConfig, zip).then(function (message) {
return build.createBuild(bsConfig, zip).then(function (data) {
let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${config.dashboardUrl}${data.build_id}`;
logger.info(message);
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null);
logger.info(dashboardLink);
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null);
return;

@@ -47,0 +50,0 @@ }).catch(function (err) {

@@ -10,3 +10,3 @@ 'use strict';

module.exports = function stop(args) {
let bsConfigPath = process.cwd() + args.cf;
let bsConfigPath = utils.getConfigPath(args.cf);

@@ -13,0 +13,0 @@ return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {

@@ -39,3 +39,3 @@ 'use strict';

let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ];
let allowedFileTypes = [ 'js', 'json', 'txt', 'ts', 'feature', 'features' ];
allowedFileTypes.forEach(fileType => {

@@ -45,7 +45,17 @@ archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json'] });

let packageJSON = {};
if (typeof runSettings.package_config_options === 'object') {
Object.assign(packageJSON, runSettings.package_config_options);
}
if (typeof runSettings.npm_dependencies === 'object') {
var packageJSON = JSON.stringify({devDependencies: runSettings.npm_dependencies}, null, 4);
archive.append(packageJSON, { name: 'browserstack-package.json' });
Object.assign(packageJSON, {devDependencies: runSettings.npm_dependencies});
}
if (Object.keys(packageJSON).length > 0) {
let packageJSONString = JSON.stringify(packageJSON, null, 4);
archive.append(packageJSONString, { name: 'browserstack-package.json' });
}
archive.finalize();

@@ -52,0 +62,0 @@ });

@@ -7,3 +7,3 @@ 'use strict';

Constants = require('../helpers/constants'),
utils =require('../helpers/utils');
utils = require('../helpers/utils');

@@ -50,3 +50,3 @@ const createBuild = (bsConfig, zip) => {

} else {
resolve(`${build.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${build.build_id}`);
resolve(build);
}

@@ -53,0 +53,0 @@ resolve(build);

@@ -14,2 +14,3 @@ var config = {};

config.buildStopUrl = `${config.cypress_v1}/builds/stop/`;
config.dashboardUrl = `https://automate.browserstack.com/dashboard/v2/builds/`;
config.usageReportingUrl = `https://eds.browserstack.com:443/send_event_cy_internal`;

@@ -16,0 +17,0 @@ config.fileName = "tests.zip";

@@ -10,6 +10,8 @@ const userMessages = {

CONFIG_FILE_EXISTS: "File already exists, delete the browserstack.json file manually. skipping...",
DIR_NOT_FOUND: "Given path does not exist. Failed to create browserstack.json in %s",
ZIP_DELETE_FAILED: "Could not delete local file.",
ZIP_DELETED: "Zip file deleted successfully.",
API_DEPRECATED: "This version of API is deprecated, please use latest version of API.",
FAILED_TO_ZIP: "Failed to zip files."
FAILED_TO_ZIP: "Failed to zip files.",
VISIT_DASHBOARD: "Visit the Automate dashboard for test reporting:"
};

@@ -16,0 +18,0 @@

@@ -9,7 +9,7 @@ 'use strict';

exports.write = function(f, message, cb) {
exports.write = function(f, message, args, cb) {
message = message || 'Creating';
fs.writeFile(f.path, f.file, function() {
logger.info(message + " file: ./" + path.relative(process.cwd(), f.path));
cb && cb()
logger.info(message + " file: " + f.path);
cb && cb(args)
});

@@ -39,1 +39,9 @@ }

}
exports.dirExists = function (filePath, cb) {
let exists = false;
if (fs.existsSync(path.dirname(filePath), cb)) {
exists = true;
}
cb && cb(exists);
}
'use strict';
const os = require("os");
const path = require("path");

@@ -106,3 +107,17 @@ const usageReporting = require('./usageReporting'),

exports.getUserAgent = () => {
return `BStack-Cypress-CLI/1.2.0 (${os.arch()}/${os.platform()}/${os.release()})`;
return `BStack-Cypress-CLI/1.3.0 (${os.arch()}/${os.platform()}/${os.release()})`;
}
exports.isAbsolute = (configPath) => {
return path.isAbsolute(configPath)
}
exports.getConfigPath = (configPath) => {
return this.isAbsolute(configPath) ? configPath : path.join(process.cwd(), configPath);
}
exports.configCreated = (args) => {
let message = Constants.userMessages.CONFIG_FILE_CREATED
logger.info(message);
this.sendUsageReport(null, args, message, Constants.messageTypes.SUCCESS, null);
}

@@ -54,3 +54,3 @@ #!/usr/bin/env node

describe: Constants.cliMessages.BUILD.DESC,
default: '/browserstack.json',
default: 'browserstack.json',
type: 'string',

@@ -95,3 +95,3 @@ nargs: 1,

describe: Constants.cliMessages.BUILD.DESC,
default: '/browserstack.json',
default: 'browserstack.json',
type: 'string',

@@ -135,3 +135,3 @@ nargs: 1,

describe: Constants.cliMessages.RUN.DESC,
default: '/browserstack.json',
default: 'browserstack.json',
type: 'string',

@@ -138,0 +138,0 @@ nargs: 1,

@@ -12,2 +12,42 @@ module.exports = function () {

"versions": ["78", "77"]
},
{
"browser": "firefox",
"os": "Windows 10",
"versions": ["74", "75"]
},
{
"browser": "edge",
"os": "Windows 10",
"versions": ["80", "81"]
},
{
"browser": "chrome",
"os": "OS X Mojave",
"versions": ["78", "77"]
},
{
"browser": "firefox",
"os": "OS X Mojave",
"versions": ["74", "75"]
},
{
"browser": "edge",
"os": "OS X Mojave",
"versions": ["80", "81"]
},
{
"browser": "chrome",
"os": "OS X Catalina",
"versions": ["78", "77"]
},
{
"browser": "firefox",
"os": "OS X Catalina",
"versions": ["74", "75"]
},
{
"browser": "edge",
"os": "OS X Catalina",
"versions": ["80", "81"]
}

@@ -21,2 +61,4 @@ ],

"npm_dependencies": {
},
"package_config_options": {
}

@@ -23,0 +65,0 @@ },

{
"name": "browserstack-cypress-cli",
"version": "1.2.0",
"version": "1.3.0",
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,3 +5,3 @@ # BrowserStack Cypress CLI

> **Note**: Running Cypress tests on BrowserStack is now in public beta. Learn more [here](https://browserstack.com/cypress)
> **Note**: Running Cypress tests on BrowserStack is now in public beta. Learn more [here](https://browserstack.com/automate/cypress)
>

@@ -8,0 +8,0 @@ > If you are looking for a getting started guide, and a more up-to date documentation, check out the [BrowserStack Cypress documentation](https://browserstack.com/docs/automate/cypress)

@@ -28,2 +28,3 @@ const chai = require("chai"),

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -58,2 +59,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -68,2 +70,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(requestStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getUserAgentStub);

@@ -94,2 +97,3 @@ sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -105,2 +109,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(getUserAgentStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

@@ -120,2 +125,3 @@ })

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -152,2 +158,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -163,2 +170,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(getUserAgentStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

@@ -194,2 +202,3 @@ })

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -205,2 +214,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(getUserAgentStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

@@ -231,2 +241,3 @@ })

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -242,2 +253,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(getUserAgentStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

@@ -259,2 +271,3 @@ })

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -289,2 +302,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -300,2 +314,3 @@ request: { get: requestStub },

sinon.assert.calledOnce(getUserAgentStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, bsConfig, args, message, messageType, errorCode);

@@ -315,2 +330,3 @@ }).catch((error) => {

setAccessKeyStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
validateBstackJsonStub = sandbox.stub();

@@ -338,2 +354,3 @@ setUsageReportingFlagStub = sandbox.stub().returns(undefined);

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -340,0 +357,0 @@ });

const chai = require("chai"),
sinon = require("sinon"),
chaiAsPromised = require("chai-as-promised");
chaiAsPromised = require("chai-as-promised"),
util = require("util");

@@ -18,4 +19,5 @@ const Constants = require("../../../../bin/helpers/constants"),

before(() => {
beforeEach(() => {
sandbox = sinon.createSandbox();
configCreatedStub = sandbox.stub()
sendUsageReportStub = sandbox.stub().callsFake(function () {

@@ -26,3 +28,3 @@ return "end";

after(() => {
afterEach(() => {
sandbox.restore();

@@ -33,3 +35,30 @@ sinon.restore();

describe("init", () => {
it("fail if given path is not present", () => {
dirExistsStub = sandbox.stub().yields(false);
writeStub = sandbox.stub();
formatStub = sandbox.stub().callsFake(function (args) {
return args;
});
const init = proxyquire("../../../../bin/commands/init", {
"../helpers/utils": {
sendUsageReport: sendUsageReportStub,
},
"../helpers/fileHelpers": {
dirExists: dirExistsStub,
write: writeStub,
},
"util": {
format: formatStub
}
});
init(args);
sinon.assert.calledOnce(dirExistsStub);
sinon.assert.notCalled(writeStub);
sinon.assert.calledOnceWithExactly(sendUsageReportStub, null, args, Constants.userMessages.DIR_NOT_FOUND, Constants.messageTypes.ERROR, 'path_to_init_not_found');
});
it("fail if browserstack.json is already present", () => {
dirExistsStub = sandbox.stub().yields(true);
fileExistsStub = sandbox.stub().yields(true);

@@ -43,2 +72,3 @@ writeStub = sandbox.stub();

"../helpers/fileHelpers": {
dirExists: dirExistsStub,
fileExists: fileExistsStub,

@@ -50,2 +80,3 @@ write: writeStub,

init(args);
sinon.assert.calledOnce(dirExistsStub);
sinon.assert.calledOnce(fileExistsStub);

@@ -57,2 +88,3 @@ sinon.assert.notCalled(writeStub);

it("create browserstack.json if not already present", () => {
dirExistsStub = sandbox.stub().yields(true);
fileExistsStub = sandbox.stub().yields(false);

@@ -64,4 +96,6 @@ writeStub = sandbox.stub();

sendUsageReport: sendUsageReportStub,
configCreated: configCreatedStub
},
"../helpers/fileHelpers": {
dirExists: dirExistsStub,
fileExists: fileExistsStub,

@@ -73,2 +107,3 @@ write: writeStub,

init(args);
sinon.assert.calledOnce(dirExistsStub);
sinon.assert.calledOnce(fileExistsStub);

@@ -75,0 +110,0 @@ sinon.assert.calledOnce(writeStub);

@@ -24,2 +24,3 @@ const chai = require("chai"),

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -48,2 +49,3 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -59,2 +61,4 @@ });

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(validateBstackJsonStub);

@@ -84,2 +88,3 @@ sinon.assert.calledOnce(setUsageReportingFlagStub);

setBuildNameStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -111,3 +116,4 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

setAccessKey: setAccessKeyStub,
setBuildName: setBuildNameStub
setBuildName: setBuildNameStub,
getConfigPath: getConfigPathStub
},

@@ -127,2 +133,4 @@ "../helpers/capabilityHelper": {

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(validateBstackJsonStub);

@@ -152,2 +160,3 @@ sinon.assert.calledOnce(capabilityValidatorStub);

setAccessKeyStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setBuildNameStub = sandbox.stub();

@@ -183,2 +192,3 @@ validateBstackJsonStub = sandbox.stub();

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -205,2 +215,4 @@ "../helpers/capabilityHelper": {

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(setParallelsStub)

@@ -234,2 +246,3 @@ sinon.assert.calledOnce(validateBstackJsonStub);

setBuildNameStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -264,2 +277,3 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -290,2 +304,4 @@ "../helpers/capabilityHelper": {

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(setParallelsStub);

@@ -323,2 +339,3 @@ sinon.assert.calledOnce(validateBstackJsonStub);

setBuildNameStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -354,2 +371,3 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -386,2 +404,4 @@ "../helpers/capabilityHelper": {

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(validateBstackJsonStub);

@@ -423,2 +443,3 @@ sinon.assert.calledOnce(capabilityValidatorStub);

setBuildNameStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -428,2 +449,3 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

});
dashboardUrl = "dashboard-url";
capabilityValidatorStub = sandbox.stub();

@@ -442,5 +464,6 @@ archiverStub = sandbox.stub();

it("send error report", () => {
let message = "build created";
let messageType = Constants.messageTypes.SUCCESS;
let errorCode = null;
let message = `Success! ${Constants.userMessages.BUILD_CREATED} with build id: random_build_id`;
let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${dashboardUrl}random_build_id`;

@@ -456,2 +479,3 @@ const runs = proxyquire("../../../../bin/commands/runs", {

setParallels: setParallelsStub,
getConfigPath: getConfigPathStub
},

@@ -473,2 +497,5 @@ "../helpers/capabilityHelper": {

},
"../helpers/config": {
dashboardUrl: dashboardUrl,
},
});

@@ -482,3 +509,3 @@

zipUploadStub.returns(Promise.resolve("zip uploaded"));
createBuildStub.returns(Promise.resolve("build created"));
createBuildStub.returns(Promise.resolve({ message: 'Success', build_id: 'random_build_id' }));

@@ -490,2 +517,4 @@ return runs(args)

.catch((error) => {
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(getConfigPathStub);
sinon.assert.calledOnce(validateBstackJsonStub);

@@ -503,3 +532,3 @@ sinon.assert.calledOnce(capabilityValidatorStub);

args,
message,
`${message}\n${dashboardLink}`,
messageType,

@@ -506,0 +535,0 @@ errorCode

@@ -28,2 +28,3 @@ const chai = require("chai"),

setAccessKeyStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -60,2 +61,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -96,2 +98,3 @@ request: { post: requestStub },

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -121,2 +124,3 @@ request: { post: requestStub },

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -153,2 +157,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -196,2 +201,3 @@ request: { post: requestStub },

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -234,2 +240,3 @@ request: { post: requestStub },

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -261,2 +268,3 @@ request: { post: requestStub },

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -293,2 +301,3 @@ getUserAgentStub = sandbox.stub().returns("random user-agent");

getUserAgent: getUserAgentStub,
getConfigPath: getConfigPathStub
},

@@ -320,2 +329,3 @@ request: { post: requestStub },

validateBstackJsonStub = sandbox.stub();
getConfigPathStub = sandbox.stub();
setUsageReportingFlagStub = sandbox.stub().returns(undefined);

@@ -342,2 +352,3 @@ sendUsageReportStub = sandbox.stub().callsFake(function () {

setUsageReportingFlag: setUsageReportingFlagStub,
getConfigPath: getConfigPathStub
},

@@ -344,0 +355,0 @@ });

@@ -179,10 +179,9 @@ const chai = require("chai"),

let build_message = "success"
let requestData = { message: build_message, build_id: build_id };
let requestStub = sandbox
.stub(request, "post")
.yields(
null,
{ statusCode: 201 },
JSON.stringify({ message: build_message, build_id: build_id })
);
.yields(null, { statusCode: 201 }, JSON.stringify(requestData));
let dashboardUrl = "dashboard-url";
const build = proxyquire("../../../../bin/helpers/build", {

@@ -195,2 +194,5 @@ "../helpers/utils": {

},
"./config": {
dashboardUrl: dashboardUrl,
},
request: { post: requestStub },

@@ -204,3 +206,3 @@ });

sinon.assert.calledOnce(getUserAgentStub);
chai.assert.equal(data, `${build_message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${build_id}`);
chai.assert.equal(data, `${requestData}`);
})

@@ -207,0 +209,0 @@ .catch((error) => {

@@ -41,3 +41,3 @@ const chai = require("chai"),

fileHelpers.write("./random_path", "writing successful", callbackStub);
fileHelpers.write("./random_path", "writing successful", {}, callbackStub);
sinon.assert.calledOnce(writeFileStub);

@@ -44,0 +44,0 @@ expect(dataMock).to.eql(1);

@@ -6,2 +6,3 @@ 'use strict';

expect = chai.expect,
sinon = require('sinon'),
chaiAsPromised = require("chai-as-promised");

@@ -11,3 +12,4 @@

constant = require('../../../../bin/helpers/constants'),
logger = require('../../../../bin/helpers/logger').winstonLogger;
logger = require('../../../../bin/helpers/logger').winstonLogger,
testObjects = require("../../support/fixtures/testObjects");

@@ -40,3 +42,3 @@ chai.use(chaiAsPromised);

});
it("should return false for a string which is not a number", () => {

@@ -206,2 +208,36 @@ expect(utils.isParallelValid("cypress")).to.be.equal(false);

});
describe("isAbsolute", () => {
it("should return true when path is absolute", () => {
expect(utils.isAbsolute("/Absolute/Path")).to.be.true;
});
it("should return false when path is relative", () => {
expect(utils.isAbsolute("../Relative/Path")).to.be.false;
});
});
describe("getConfigPath", () => {
it("should return given path, when path is absolute", () => {
expect(utils.getConfigPath("/Absolute/Path")).to.be.eq("/Absolute/Path");
});
it("should return path joined with current dir path, when path is relative", () => {
let configPath = "../Relative/Path"
expect(utils.getConfigPath(configPath)).to.be.eq(path.join(process.cwd(), configPath));
});
});
describe("configCreated", () => {
let args = testObjects.initSampleArgs;
it("should call sendUsageReport", () => {
sandbox = sinon.createSandbox();
sendUsageReportStub = sandbox.stub(utils, "sendUsageReport").callsFake(function () {
return "end";
});
utils.configCreated(args);
sinon.assert.calledOnce(sendUsageReportStub);
});
});
});

@@ -22,5 +22,5 @@ const sampleBsConfig = {

_: ["build-info", "f3c94f7203792d03a75be3912d19354fe0961e53"],
cf: "/browserstack.json",
"config-file": "/browserstack.json",
configFile: "/browserstack.json",
cf: "browserstack.json",
"config-file": "browserstack.json",
configFile: "browserstack.json",
"disable-usage-reporting": undefined,

@@ -85,5 +85,5 @@ disableUsageReporting: undefined,

_: ["build-stop", "f3c94f7203792d03a75be3912d19354fe0961e53"],
cf: "/browserstack.json",
"config-file": "/browserstack.json",
configFile: "/browserstack.json",
cf: "browserstack.json",
"config-file": "browserstack.json",
configFile: "browserstack.json",
"disable-usage-reporting": undefined,

@@ -105,5 +105,5 @@ disableUsageReporting: undefined,

_: ["run"],
cf: "/browserstack.json",
"config-file": "/browserstack.json",
configFile: "/browserstack.json",
cf: "browserstack.json",
"config-file": "browserstack.json",
configFile: "browserstack.json",
"disable-usage-reporting": undefined,

@@ -110,0 +110,0 @@ p: undefined,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc