browserstack-cypress-cli
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -9,12 +9,43 @@ 'use strict'; | ||
module.exports = function init(args) { | ||
if (args.p) { | ||
var path_to_bsconf = path.join(args.p + "/browserstack.json"); | ||
} else { | ||
var path_to_bsconf = "./browserstack.json"; | ||
function get_path(args) { | ||
if (args._.length > 1 && args.p) { | ||
let filename = args._[1]; | ||
if (filename !== path.basename(filename)) { | ||
let message = Constants.userMessages.CONFLICTING_INIT_ARGUMENTS; | ||
logger.error(message); | ||
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init'); | ||
return; | ||
} | ||
return path.join(args.p, filename); | ||
} else if (args.p) { | ||
return path.join(args.p, "browserstack.json"); | ||
} else if (args._.length > 1) { | ||
let filename = args._[1]; | ||
if (filename !== path.basename(filename)) { | ||
// filename is an absolute path | ||
return filename; | ||
} | ||
return path.join(process.cwd(), args._[1]); | ||
} | ||
var config = { | ||
return path.join(process.cwd(), "browserstack.json"); | ||
} | ||
module.exports = function init(args) { | ||
let path_to_json = get_path(args); | ||
if (path_to_json === undefined) return; | ||
// append .json if filename passed is not of json type | ||
if (path.extname(path_to_json) !== '' && path.extname(path_to_json) !== ".json") path_to_json += ".json"; | ||
// append browserstack.json if filename is a path without filename | ||
if (path.extname(path_to_json) === '') path_to_json = path.join(path_to_json, "browserstack.json"); | ||
let config = { | ||
file: require('../templates/configTemplate')(), | ||
path: path_to_bsconf | ||
path: path_to_json | ||
}; | ||
@@ -21,0 +52,0 @@ |
@@ -29,2 +29,5 @@ 'use strict'; | ||
// set cypress config filename | ||
utils.setCypressConfigFilename(bsConfig, args); | ||
// accept the specs list from command line if provided | ||
@@ -31,0 +34,0 @@ utils.setUserSpecs(bsConfig, args); |
@@ -7,3 +7,4 @@ 'use strict'; | ||
logger = require("./logger").winstonLogger, | ||
utils = require('../helpers/utils'); | ||
utils = require('../helpers/utils'), | ||
path = require('path'); | ||
@@ -14,3 +15,3 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => { | ||
var cypressFolderPath = runSettings.cypress_proj_dir; | ||
var cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath); | ||
@@ -64,2 +65,9 @@ var archive = archiver('zip', { | ||
// do not add cypress.json if arg provided is false | ||
if (runSettings.cypress_config_file && runSettings.cypress_config_filename !== 'false') { | ||
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath)); | ||
let cypressJSONString = JSON.stringify(cypressJSON, null, 4); | ||
archive.append(cypressJSONString, { name: 'cypress.json' }); | ||
} | ||
archive.finalize(); | ||
@@ -66,0 +74,0 @@ }); |
@@ -71,2 +71,6 @@ const logger = require("./logger").winstonLogger, | ||
if (!Utils.isUndefined(bsConfig.run_settings.cypress_config_filename)) { | ||
obj.cypress_config_filename = bsConfig.run_settings.cypress_config_filename; | ||
} | ||
if (!Utils.isUndefined(bsConfig.run_settings.specs)){ | ||
@@ -82,3 +86,3 @@ obj.specs = bsConfig.run_settings.specs; | ||
if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined | ||
if (obj.project) logger.log(`Project name is: ${obj.project}`); | ||
@@ -111,3 +115,5 @@ | ||
if (!bsConfig.run_settings.cypress_proj_dir) reject(Constants.validationMessages.EMPTY_CYPRESS_PROJ_DIR); | ||
if (!bsConfig.run_settings.cypress_proj_dir && !bsConfig.run_settings.userProvidedCypessConfigFile) { | ||
reject(Constants.validationMessages.EMPTY_CYPRESS_PROJ_DIR); | ||
} | ||
@@ -120,14 +126,20 @@ // validate parallels specified in browserstack.json if parallels are not specified via arguments | ||
if (!fs.existsSync(path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json'))) reject(Constants.validationMessages.CYPRESS_JSON_NOT_FOUND + bsConfig.run_settings.cypress_proj_dir); | ||
// validate if config file provided exists or not when cypress_config_file provided | ||
// validate the cypressProjectDir key otherwise. | ||
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath; | ||
if (!fs.existsSync(cypressConfigFilePath) && bsConfig.run_settings.cypress_config_filename !== 'false') reject(Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE); | ||
try { | ||
let cypressJson = fs.readFileSync(path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json')); | ||
cypressJson = JSON.parse(cypressJson); | ||
// Cypress Json Base Url & Local true check | ||
if (!Utils.isUndefined(cypressJson.baseUrl) && cypressJson.baseUrl.includes("localhost") && !Utils.getLocalFlag(bsConfig.connection_settings)) reject(Constants.validationMessages.LOCAL_NOT_SET); | ||
// Detect if the user is not using the right directory structure, and throw an error | ||
if (!Utils.isUndefined(cypressJson.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypress_proj_dir,cypressJson.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE); | ||
if (bsConfig.run_settings.cypress_config_filename !== 'false') { | ||
let cypressJsonContent = fs.readFileSync(cypressConfigFilePath); | ||
cypressJson = JSON.parse(cypressJsonContent); | ||
} catch (error) { | ||
// Cypress Json Base Url & Local true check | ||
if (!Utils.isUndefined(cypressJson.baseUrl) && cypressJson.baseUrl.includes("localhost") && !Utils.getLocalFlag(bsConfig.connection_settings)) reject(Constants.validationMessages.LOCAL_NOT_SET); | ||
// Detect if the user is not using the right directory structure, and throw an error | ||
if (!Utils.isUndefined(cypressJson.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypressProjectDir,cypressJson.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE); | ||
} | ||
} catch(error){ | ||
reject(Constants.validationMessages.INVALID_CYPRESS_JSON) | ||
@@ -134,0 +146,0 @@ } |
@@ -16,2 +16,3 @@ const userMessages = { | ||
VISIT_DASHBOARD: "Visit the Automate dashboard for test reporting:", | ||
CONFLICTING_INIT_ARGUMENTS: "Conflicting arguments given. You can use --path only with a file name, and not with a file path.", | ||
NO_PARALLELS: "Your tests will run sequentially. Read more about running your tests in parallel here: https://www.browserstack.com/docs/automate/cypress/run-tests-in-parallel", | ||
@@ -33,2 +34,3 @@ NO_NPM_DEPENDENCIES: "No npm dependencies specified. Read more here: https://www.browserstack.com/docs/automate/cypress/npm-packages. You can suppress this warning by using --disable-npm-warning flag." | ||
INVALID_PARALLELS_CONFIGURATION: "Invalid value specified for parallels to use. Maximum parallels to use should be a number greater than 0.", | ||
INVALID_CYPRESS_CONFIG_FILE: "Invalid cypress_config_file", | ||
CYPRESS_JSON_NOT_FOUND: "cypress.json file is not found at cypress_proj_dir path ", | ||
@@ -64,3 +66,5 @@ INVALID_CYPRESS_JSON: "cypress.json is not a valid json", | ||
DESC: "Path to BrowserStack config", | ||
CYPRESS_DESC: "Path to Cypress config file", | ||
CONFIG_DEMAND: "config file is required", | ||
CYPRESS_CONFIG_DEMAND: "Cypress config file is required", | ||
BUILD_NAME: "The build name you want to use to name your test runs", | ||
@@ -91,3 +95,3 @@ EXCLUDE: "Exclude files matching a pattern from zipping and uploading", | ||
const filesToIgnoreWhileUploading = ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip'] | ||
const filesToIgnoreWhileUploading = ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip', 'cypress.json'] | ||
@@ -94,0 +98,0 @@ module.exports = Object.freeze({ |
@@ -130,3 +130,3 @@ 'use strict'; | ||
if (env.CI === "true" && env.CIRCLECI === "true") { | ||
return "CircleCI"; | ||
return "CircleCI"; | ||
} | ||
@@ -133,0 +133,0 @@ // Travis CI |
@@ -58,2 +58,5 @@ "use strict"; | ||
break; | ||
case Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE: | ||
errorCode = "invalid_cypress_config_file"; | ||
break; | ||
} | ||
@@ -144,2 +147,39 @@ if ( | ||
exports.searchForOption = (option) => { | ||
return (process.argv.indexOf(option) > -1); | ||
} | ||
exports.verifyCypressConfigFileOption = () => { | ||
let ccfOptionsSet = (this.searchForOption('-ccf') || this.searchForOption('--ccf')); | ||
let cypressConfigFileSet = (this.searchForOption('-cypress-config-file') || this.searchForOption('--cypress-config-file')); | ||
let cypressConfigOptionsSet = (this.searchForOption('-cypressConfigFile') || this.searchForOption('--cypressConfigFile')); | ||
return (ccfOptionsSet || cypressConfigFileSet || cypressConfigOptionsSet); | ||
} | ||
// TODO: Remove when cleaningup cypress_proj_dir | ||
// | ||
// 1. Remove demand from runner.js for --ccf option. | ||
// 2. Remove the strict check functions: verifyCypressConfigFileOption | ||
// 3. Just use the args.cypressConfigFile for checking the value for cypress config file. | ||
exports.setCypressConfigFilename = (bsConfig, args) => { | ||
let userProvidedCypessConfigFile = this.verifyCypressConfigFileOption(); | ||
bsConfig.run_settings.userProvidedCypessConfigFile = (userProvidedCypessConfigFile || (!this.isUndefined(bsConfig.run_settings.cypress_config_file))); | ||
if (userProvidedCypessConfigFile || this.isUndefined(bsConfig.run_settings.cypress_config_file)) { | ||
bsConfig.run_settings.cypress_config_file = args.cypressConfigFile; | ||
bsConfig.run_settings.cypress_config_filename = path.basename(args.cypressConfigFile); | ||
} else if (!this.isUndefined(bsConfig.run_settings.cypress_config_file)) { | ||
bsConfig.run_settings.cypress_config_filename = path.basename(bsConfig.run_settings.cypress_config_file); | ||
} | ||
if (bsConfig.run_settings.userProvidedCypessConfigFile){ | ||
bsConfig.run_settings.cypressConfigFilePath = bsConfig.run_settings.cypress_config_file; | ||
bsConfig.run_settings.cypressProjectDir = path.dirname(bsConfig.run_settings.cypress_config_file); | ||
} else { | ||
bsConfig.run_settings.cypressConfigFilePath = path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json'); | ||
bsConfig.run_settings.cypressProjectDir = bsConfig.run_settings.cypress_proj_dir; | ||
} | ||
} | ||
// specs can be passed from bstack configuration file | ||
@@ -184,3 +224,3 @@ // specs can be passed via command line args as a string | ||
exports.getUserAgent = () => { | ||
return `BStack-Cypress-CLI/1.4.0 (${os.arch()}/${os.platform()}/${os.release()})`; | ||
return `BStack-Cypress-CLI/1.5.0 (${os.arch()}/${os.platform()}/${os.release()})`; | ||
}; | ||
@@ -187,0 +227,0 @@ |
@@ -25,3 +25,3 @@ #!/usr/bin/env node | ||
argv = yargs | ||
.usage("usage: $0 init [options]") | ||
.usage("usage: $0 init [filename] [options]") | ||
.options({ | ||
@@ -140,2 +140,11 @@ 'p': { | ||
}, | ||
'ccf': { | ||
alias: 'cypress-config-file', | ||
describe: Constants.cliMessages.RUN.CYPRESS_DESC, | ||
default: './cypress.json', | ||
type: 'string', | ||
nargs: 1, | ||
demand: true, | ||
demand: Constants.cliMessages.RUN.CYPRESS_CONFIG_DEMAND | ||
}, | ||
'disable-usage-reporting': { | ||
@@ -142,0 +151,0 @@ default: undefined, |
@@ -11,3 +11,3 @@ module.exports = function () { | ||
"os": "Windows 10", | ||
"versions": ["78", "77"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -17,3 +17,3 @@ { | ||
"os": "Windows 10", | ||
"versions": ["74", "75"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -23,3 +23,3 @@ { | ||
"os": "Windows 10", | ||
"versions": ["80", "81"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -29,3 +29,3 @@ { | ||
"os": "OS X Mojave", | ||
"versions": ["78", "77"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -35,3 +35,3 @@ { | ||
"os": "OS X Mojave", | ||
"versions": ["74", "75"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -41,3 +41,3 @@ { | ||
"os": "OS X Mojave", | ||
"versions": ["80", "81"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -47,3 +47,3 @@ { | ||
"os": "OS X Catalina", | ||
"versions": ["78", "77"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -53,3 +53,3 @@ { | ||
"os": "OS X Catalina", | ||
"versions": ["74", "75"] | ||
"versions": ["latest", "latest-1"] | ||
}, | ||
@@ -59,7 +59,7 @@ { | ||
"os": "OS X Catalina", | ||
"versions": ["80", "81"] | ||
"versions": ["latest", "latest-1"] | ||
} | ||
], | ||
"run_settings": { | ||
"cypress_proj_dir" : "/path/to/directory-that-contains-<cypress.json>-file", | ||
"cypress_config_file" : "/path/to/<cypress config file>.json", | ||
"project_name": "project-name", | ||
@@ -66,0 +66,0 @@ "build_name": "build-name", |
{ | ||
"name": "browserstack-cypress-cli", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
const chai = require("chai"), | ||
assert = chai.assert, | ||
expect = chai.expect, | ||
sinon = require("sinon"), | ||
chaiAsPromised = require("chai-as-promised"), | ||
util = require("util"); | ||
rewire = require("rewire"), | ||
util = require("util"), | ||
path = require('path'); | ||
const Constants = require("../../../../bin/helpers/constants"), | ||
logger = require("../../../../bin/helpers/logger").winstonLogger, | ||
testObjects = require("../../support/fixtures/testObjects"); | ||
testObjects = require("../../support/fixtures/testObjects") | ||
utils = require("../../../../bin/helpers/utils"); | ||
const proxyquire = require("proxyquire").noCallThru(); | ||
const get_path = rewire("../../../../bin/commands/init").__get__("get_path");; | ||
chai.use(chaiAsPromised); | ||
@@ -32,2 +39,75 @@ logger.transports["console.info"].silent = true; | ||
describe("get_path", () => { | ||
it("filename passed, -path passed", () => { | ||
let args = { | ||
_: ["init", "filename.json"], | ||
p: '/sample-path', | ||
path: '/sample-path', | ||
$0: "browserstack-cypress", | ||
}; | ||
expect(get_path(args)).to.be.eql('/sample-path/filename.json'); | ||
}); | ||
it("filename passed, -path not passed", () => { | ||
let args = { | ||
_: ["init", "filename.json"], | ||
p: false, | ||
path: false, | ||
$0: "browserstack-cypress", | ||
}; | ||
let args2 = { | ||
_: ["init", "~/filename.json"], | ||
p: false, | ||
path: false, | ||
$0: "browserstack-cypress", | ||
}; | ||
expect(get_path(args)).to.be.eql(path.join(process.cwd(), 'filename.json')); | ||
expect(get_path(args2)).to.be.eql('~/filename.json'); | ||
}); | ||
it("filepath passed, -path passed", () => { | ||
let args = { | ||
_: ["init", "/sample-path/filename.json"], | ||
p: '/sample-path2', | ||
path: '/sample-path2', | ||
"disable-usage-reporting": undefined, | ||
disableUsageReporting: undefined, | ||
$0: "browserstack-cypress", | ||
}; | ||
loggerStub = sandbox.stub(logger, 'error'); | ||
usageStub = sandbox.stub(utils, 'sendUsageReport'); | ||
expect(get_path(args)).to.be.undefined; | ||
sinon.assert.calledOnce(loggerStub); | ||
sinon.assert.calledOnce(usageStub); | ||
}); | ||
it("filename not passed, -path passed", () => { | ||
let args = { | ||
_: ["init"], | ||
p: '/sample-path', | ||
path: '/sample-path', | ||
$0: "browserstack-cypress", | ||
}; | ||
expect(get_path(args)).to.be.eql('/sample-path/browserstack.json'); | ||
}); | ||
it("filename not passed, -path not passed", () => { | ||
let args = { | ||
_: ["init"], | ||
p: false, | ||
path: false, | ||
$0: "browserstack-cypress", | ||
}; | ||
expect(get_path(args)).to.be.eql(path.join(process.cwd(), 'browserstack.json')); | ||
}); | ||
}); | ||
describe("init", () => { | ||
@@ -34,0 +114,0 @@ it("fail if given path is not present", () => { |
@@ -88,2 +88,3 @@ const chai = require("chai"), | ||
setBuildNameStub = sandbox.stub(); | ||
setCypressConfigFilenameStub = sandbox.stub(); | ||
setUserSpecsStub = sandbox.stub(); | ||
@@ -122,2 +123,3 @@ setTestEnvsStub = sandbox.stub(); | ||
setBuildName: setBuildNameStub, | ||
setCypressConfigFilename: setCypressConfigFilenameStub, | ||
setUserSpecs: setUserSpecsStub, | ||
@@ -174,2 +176,3 @@ setTestEnvs: setTestEnvsStub, | ||
setBuildNameStub = sandbox.stub(); | ||
setCypressConfigFilenameStub = sandbox.stub(); | ||
setUserSpecsStub = sandbox.stub(); | ||
@@ -208,2 +211,3 @@ setTestEnvsStub = sandbox.stub(); | ||
setBuildName: setBuildNameStub, | ||
setCypressConfigFilename: setCypressConfigFilenameStub, | ||
setUserSpecs: setUserSpecsStub, | ||
@@ -270,2 +274,3 @@ setTestEnvs: setTestEnvsStub, | ||
setBuildNameStub = sandbox.stub(); | ||
setCypressConfigFilenameStub = sandbox.stub(); | ||
setUserSpecsStub = sandbox.stub(); | ||
@@ -305,2 +310,3 @@ setTestEnvsStub = sandbox.stub(); | ||
setBuildName: setBuildNameStub, | ||
setCypressConfigFilename: setCypressConfigFilenameStub, | ||
setUserSpecs: setUserSpecsStub, | ||
@@ -374,2 +380,3 @@ setTestEnvs: setTestEnvsStub, | ||
setBuildNameStub = sandbox.stub(); | ||
setCypressConfigFilenameStub = sandbox.stub(); | ||
setUserSpecsStub = sandbox.stub(); | ||
@@ -410,2 +417,3 @@ setTestEnvsStub = sandbox.stub(); | ||
setBuildName: setBuildNameStub, | ||
setCypressConfigFilename: setCypressConfigFilenameStub, | ||
setUserSpecs: setUserSpecsStub, | ||
@@ -490,2 +498,3 @@ setTestEnvs: setTestEnvsStub, | ||
setBuildNameStub = sandbox.stub(); | ||
setCypressConfigFilenameStub = sandbox.stub(); | ||
setUserSpecsStub = sandbox.stub(); | ||
@@ -529,2 +538,3 @@ setTestEnvsStub = sandbox.stub(); | ||
setBuildName: setBuildNameStub, | ||
setCypressConfigFilename: setCypressConfigFilenameStub, | ||
setUserSpecs: setUserSpecsStub, | ||
@@ -531,0 +541,0 @@ setTestEnvs: setTestEnvsStub, |
@@ -402,3 +402,4 @@ const chai = require("chai"), | ||
run_settings: { | ||
cypress_proj_dir: "random path" | ||
cypress_proj_dir: "random path", | ||
cypressConfigFilePath: "random path" | ||
}, | ||
@@ -785,3 +786,5 @@ }; | ||
run_settings: { | ||
cypress_proj_dir: "random path" | ||
cypress_proj_dir: "random path", | ||
cypressConfigFilePath: "random path", | ||
cypressProjectDir: "random path" | ||
}, | ||
@@ -802,3 +805,3 @@ }; | ||
error, | ||
Constants.validationMessages.CYPRESS_JSON_NOT_FOUND + "random path" | ||
Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE | ||
); | ||
@@ -864,2 +867,3 @@ fs.existsSync.restore(); | ||
); | ||
fs.existsSync.restore(); | ||
@@ -869,4 +873,35 @@ fs.readFileSync.restore(); | ||
}); | ||
context("cypress config file set to false", () => { | ||
beforeEach(function() { | ||
readFileSpy = sinon.stub(fs, 'readFileSync'); | ||
jsonParseSpy = sinon.stub(JSON, 'parse'); | ||
}); | ||
afterEach(function() { | ||
readFileSpy.restore(); | ||
jsonParseSpy.restore(); | ||
}); | ||
it("does not validate with cypress config filename set to false", () => { | ||
// sinon.stub(fs, 'existsSync').returns(false); | ||
bsConfig.run_settings.cypressConfigFilePath = 'false'; | ||
bsConfig.run_settings.cypress_config_filename = 'false'; | ||
return capabilityHelper | ||
.validate(bsConfig, {}) | ||
.then(function (data) { | ||
sinon.assert.notCalled(readFileSpy); | ||
sinon.assert.notCalled(jsonParseSpy); | ||
}) | ||
.catch((error) => { | ||
chai.assert.equal( | ||
error, | ||
Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE | ||
); | ||
}); | ||
}) | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -343,3 +343,3 @@ const cp = require("child_process"), | ||
}); | ||
describe("ci_environment", () => { | ||
@@ -346,0 +346,0 @@ afterEach(() => { |
@@ -690,2 +690,124 @@ 'use strict'; | ||
}); | ||
describe("verifyCypressConfigFileOption", () => { | ||
let utilsearchForOptionCypressConfigFileStub, userOption, testOption; | ||
beforeEach(function() { | ||
utilsearchForOptionCypressConfigFileStub = sinon | ||
.stub(utils, 'searchForOption') | ||
.callsFake((...userOption) => { | ||
return (userOption == testOption); | ||
}); | ||
}); | ||
afterEach(function() { | ||
utilsearchForOptionCypressConfigFileStub.restore(); | ||
}); | ||
it("-ccf user option", () => { | ||
testOption = '-ccf'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
it("--ccf user option", () => { | ||
testOption = '--ccf'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
it("-cypress-config-file user option", () => { | ||
testOption = '-cypress-config-file'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
it("--cypress-config-file user option", () => { | ||
testOption = '--cypress-config-file'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
it("-cypressConfigFile user option", () => { | ||
testOption = '-cypressConfigFile'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
it("--cypressConfigFile user option", () => { | ||
testOption = '--cypressConfigFile'; | ||
expect(utils.verifyCypressConfigFileOption()).to.be.true; | ||
sinon.assert.calledWithExactly(utilsearchForOptionCypressConfigFileStub, testOption); | ||
}); | ||
}); | ||
describe("setCypressConfigFilename", () => { | ||
let verifyCypressConfigFileOptionStub, | ||
ccfBool, args, bsConfig, cypress_config_file; | ||
beforeEach(function() { | ||
verifyCypressConfigFileOptionStub = sinon | ||
.stub(utils, 'verifyCypressConfigFileOption') | ||
.callsFake(() => ccfBool); | ||
args = { | ||
cypressConfigFile: "args_cypress_config_file" | ||
}; | ||
}); | ||
it("has user provided ccf flag", () => { | ||
ccfBool = true; | ||
bsConfig = { | ||
run_settings: { | ||
cypress_config_file: "run_settings_cypress_config_file" | ||
} | ||
}; | ||
utils.setCypressConfigFilename(bsConfig, args); | ||
expect(bsConfig.run_settings.cypress_config_file).to.be.eq(args.cypressConfigFile); | ||
expect(bsConfig.run_settings.cypress_config_filename).to.be.eq(path.basename(args.cypressConfigFile)); | ||
expect(bsConfig.run_settings.userProvidedCypessConfigFile).to.be.true; | ||
expect(bsConfig.run_settings.cypressConfigFilePath).to.be.eq(bsConfig.run_settings.cypress_config_file); | ||
}); | ||
it("does not have user provided ccf flag, sets the value from cypress_proj_dir", () => { | ||
ccfBool = false; | ||
bsConfig = { | ||
run_settings: { | ||
cypress_proj_dir: "cypress_proj_dir" | ||
} | ||
}; | ||
utils.setCypressConfigFilename(bsConfig, args); | ||
expect(bsConfig.run_settings.cypress_config_file).to.be.eq(args.cypressConfigFile); | ||
expect(bsConfig.run_settings.cypress_config_filename).to.be.eq(path.basename(args.cypressConfigFile)); | ||
expect(bsConfig.run_settings.userProvidedCypessConfigFile).to.be.false; | ||
expect(bsConfig.run_settings.cypressConfigFilePath).to.be.eq(path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json')); | ||
}); | ||
it("does not have user provided ccf flag, sets from config file", () => { | ||
cypress_config_file = "run_settings_cypress_config_file"; | ||
ccfBool = false; | ||
bsConfig = { | ||
run_settings: { | ||
cypress_config_file: cypress_config_file | ||
} | ||
}; | ||
utils.setCypressConfigFilename(bsConfig, args); | ||
expect(bsConfig.run_settings.cypress_config_file).to.be.eq(cypress_config_file); | ||
expect(bsConfig.run_settings.cypress_config_filename).to.be.eq(path.basename(cypress_config_file)); | ||
expect(bsConfig.run_settings.userProvidedCypessConfigFile).to.be.true; | ||
expect(bsConfig.run_settings.cypressConfigFilePath).to.be.eq(bsConfig.run_settings.cypress_config_file); | ||
}); | ||
afterEach(function() { | ||
verifyCypressConfigFileOptionStub.restore(); | ||
}) | ||
}); | ||
}); |
@@ -7,3 +7,5 @@ const sampleBsConfig = { | ||
run_settings: { | ||
cypress_proj_dir: "random path" | ||
cypress_proj_dir: "random path", | ||
cypressConfigFilePath: "random path", | ||
cypressProjectDir: "random path" | ||
} | ||
@@ -10,0 +12,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202950
5279