browserstack-cypress-cli 1.15.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/runs.js +8 -3
- package/bin/helpers/archiver.js +8 -5
- package/bin/helpers/buildArtifacts.js +3 -3
- package/bin/helpers/capabilityHelper.js +47 -15
- package/bin/helpers/checkUploaded.js +8 -5
- package/bin/helpers/constants.js +268 -112
- package/bin/helpers/packageInstaller.js +19 -3
- package/bin/helpers/reporterHTML.js +55 -262
- package/bin/helpers/usageReporting.js +3 -3
- package/bin/helpers/utils.js +98 -20
- package/bin/runner.js +6 -1
- package/package.json +2 -2
- package/log/usage.log +0 -2
package/bin/commands/runs.js
CHANGED
|
@@ -61,6 +61,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
61
61
|
// set cypress config filename
|
|
62
62
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
63
63
|
|
|
64
|
+
// set cypress test suite type
|
|
65
|
+
utils.setCypressTestSuiteType(bsConfig);
|
|
66
|
+
|
|
64
67
|
// set cypress geo location
|
|
65
68
|
utils.setGeolocation(bsConfig, args);
|
|
66
69
|
|
|
@@ -97,6 +100,8 @@ module.exports = function run(args, rawArgs) {
|
|
|
97
100
|
// set record feature caps
|
|
98
101
|
utils.setRecordCaps(bsConfig, args);
|
|
99
102
|
|
|
103
|
+
// set build tag caps
|
|
104
|
+
utils.setBuildTags(bsConfig, args);
|
|
100
105
|
// set node version
|
|
101
106
|
utils.setNodeVersion(bsConfig, args);
|
|
102
107
|
|
|
@@ -117,15 +122,15 @@ module.exports = function run(args, rawArgs) {
|
|
|
117
122
|
// Validate browserstack.json values and parallels specified via arguments
|
|
118
123
|
markBlockStart('validateConfig');
|
|
119
124
|
logger.debug("Started configs validation");
|
|
120
|
-
return capabilityHelper.validate(bsConfig, args).then(function (
|
|
125
|
+
return capabilityHelper.validate(bsConfig, args).then(function (cypressConfigFile) {
|
|
121
126
|
markBlockEnd('validateConfig');
|
|
122
127
|
logger.debug("Completed configs validation");
|
|
123
128
|
markBlockStart('preArchiveSteps');
|
|
124
129
|
logger.debug("Started pre-archive steps");
|
|
125
130
|
//get the number of spec files
|
|
126
|
-
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args,
|
|
131
|
+
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile);
|
|
127
132
|
|
|
128
|
-
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(
|
|
133
|
+
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressConfigFile);
|
|
129
134
|
|
|
130
135
|
// return the number of parallels user specified
|
|
131
136
|
let userSpecifiedParallels = utils.getParallels(bsConfig, args);
|
package/bin/helpers/archiver.js
CHANGED
|
@@ -81,11 +81,14 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
81
81
|
runSettings.cypress_config_file &&
|
|
82
82
|
runSettings.cypress_config_filename !== 'false'
|
|
83
83
|
) {
|
|
84
|
-
|
|
85
|
-
fs.readFileSync(runSettings.cypressConfigFilePath)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
85
|
+
let cypressConfigFileString = fs.readFileSync(runSettings.cypressConfigFilePath, {encoding: "utf-8"});
|
|
86
|
+
archive.append(cypressConfigFileString, {name: `${cypressAppendFilesZipLocation}${runSettings.cypress_config_filename}`});
|
|
87
|
+
} else if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V9_AND_OLDER_TYPE) {
|
|
88
|
+
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
|
|
89
|
+
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
|
|
90
|
+
archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
archive.finalize();
|
|
@@ -137,13 +137,13 @@ const unzipFile = async (filePath, fileName) => {
|
|
|
137
137
|
const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, buildReportData) => {
|
|
138
138
|
options.url = `${config.buildUrl}${buildId}/build_artifacts/status`;
|
|
139
139
|
|
|
140
|
-
let
|
|
140
|
+
let cypressConfigFile = utils.getCypressConfigFile(bsConfig);
|
|
141
141
|
|
|
142
142
|
let reporter = null;
|
|
143
143
|
if(!utils.isUndefined(args.reporter)) {
|
|
144
144
|
reporter = args.reporter;
|
|
145
|
-
} else if(
|
|
146
|
-
reporter =
|
|
145
|
+
} else if(cypressConfigFile !== undefined){
|
|
146
|
+
reporter = cypressConfigFile.reporter;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
let data = {
|
|
@@ -162,8 +162,8 @@ const validate = (bsConfig, args) => {
|
|
|
162
162
|
|
|
163
163
|
if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS);
|
|
164
164
|
|
|
165
|
-
if (!bsConfig.run_settings.
|
|
166
|
-
reject(Constants.validationMessages.
|
|
165
|
+
if (!bsConfig.run_settings.cypressConfigFilePath && !bsConfig.run_settings.userProvidedCypessConfigFile) {
|
|
166
|
+
reject(Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// validate parallels specified in browserstack.json if parallels are not specified via arguments
|
|
@@ -189,25 +189,39 @@ const validate = (bsConfig, args) => {
|
|
|
189
189
|
// validate if config file provided exists or not when cypress_config_file provided
|
|
190
190
|
// validate the cypressProjectDir key otherwise.
|
|
191
191
|
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
|
|
192
|
-
let
|
|
192
|
+
let cypressConfigFile = {};
|
|
193
193
|
|
|
194
194
|
logger.debug(`Checking for cypress config file at ${cypressConfigFilePath}`);
|
|
195
195
|
if (!fs.existsSync(cypressConfigFilePath) && bsConfig.run_settings.cypress_config_filename !== 'false') reject(Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE);
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
198
|
+
logger.debug(`Validating ${bsConfig.run_settings.cypress_config_filename}`);
|
|
199
|
+
// TODO: add validations for cypress_config_filename
|
|
200
|
+
} else {
|
|
201
|
+
logger.debug("Validating cypress.json");
|
|
202
|
+
try {
|
|
203
|
+
if (bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
204
|
+
|
|
205
|
+
if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
206
|
+
if (cypressConfigFilePath.endsWith("cypress.config.js")) {
|
|
207
|
+
cypressConfigFile = require(cypressConfigFilePath);
|
|
208
|
+
} else {
|
|
209
|
+
cypressConfigFile = {};
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
let cypressJsonContent = fs.readFileSync(cypressConfigFilePath);
|
|
213
|
+
cypressConfigFile = JSON.parse(cypressJsonContent);
|
|
214
|
+
}
|
|
202
215
|
|
|
203
|
-
|
|
204
|
-
|
|
216
|
+
// Cypress Json Base Url & Local true check
|
|
217
|
+
if (!Utils.isUndefined(cypressConfigFile.baseUrl) && cypressConfigFile.baseUrl.includes("localhost") && !Utils.getLocalFlag(bsConfig.connection_settings)) reject(Constants.validationMessages.LOCAL_NOT_SET.replace("<baseUrlValue>", cypressConfigFile.baseUrl));
|
|
205
218
|
|
|
206
|
-
|
|
207
|
-
|
|
219
|
+
// Detect if the user is not using the right directory structure, and throw an error
|
|
220
|
+
if (!Utils.isUndefined(cypressConfigFile.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypressProjectDir,cypressConfigFile.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE);
|
|
221
|
+
}
|
|
222
|
+
} catch(error){
|
|
223
|
+
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
208
224
|
}
|
|
209
|
-
} catch(error){
|
|
210
|
-
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
211
225
|
}
|
|
212
226
|
|
|
213
227
|
//check if home_directory is present or not in user run_settings
|
|
@@ -231,6 +245,24 @@ const validate = (bsConfig, args) => {
|
|
|
231
245
|
addCypressZipStartLocation(bsConfig.run_settings);
|
|
232
246
|
}
|
|
233
247
|
|
|
248
|
+
// check if two config files are present at the same location
|
|
249
|
+
let cypressFileDirectory = path.dirname(path.resolve(bsConfig.run_settings.cypressConfigFilePath));
|
|
250
|
+
let listOfFiles = fs.readdirSync(cypressFileDirectory);
|
|
251
|
+
let configFilesPresent = [];
|
|
252
|
+
for (const possibleCypressFileName of Constants.CYPRESS_CONFIG_FILE_NAMES) {
|
|
253
|
+
if (listOfFiles.includes(possibleCypressFileName)) {
|
|
254
|
+
configFilesPresent.push(possibleCypressFileName);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (configFilesPresent.length === 0 && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
259
|
+
reject(Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_FOUND.replace('<location>', cypressFileDirectory));
|
|
260
|
+
}
|
|
261
|
+
if (configFilesPresent.length > 1 && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
262
|
+
logger.warn(`We found the following cypress config files ${configFilesPresent.join(', ')} at this location: ${cypressFileDirectory}`);
|
|
263
|
+
reject(Constants.validationMessages.MORE_THAN_ONE_CYPRESS_CONFIG_FILE_FOUND);
|
|
264
|
+
}
|
|
265
|
+
|
|
234
266
|
if(!Utils.isUndefined(bsConfig.run_settings.spec_timeout)) {
|
|
235
267
|
if(Utils.isPositiveInteger(bsConfig.run_settings.spec_timeout.toString().trim())) {
|
|
236
268
|
if(Number(bsConfig.run_settings.spec_timeout) > Constants.SPEC_TIMEOUT_LIMIT) {
|
|
@@ -257,7 +289,7 @@ const validate = (bsConfig, args) => {
|
|
|
257
289
|
if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/))
|
|
258
290
|
logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR);
|
|
259
291
|
|
|
260
|
-
resolve(
|
|
292
|
+
resolve(cypressConfigFile);
|
|
261
293
|
});
|
|
262
294
|
}
|
|
263
295
|
|
|
@@ -37,11 +37,14 @@ const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
|
37
37
|
runSettings.cypress_config_file &&
|
|
38
38
|
runSettings.cypress_config_filename !== 'false'
|
|
39
39
|
) {
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
let cypressConfigFileString = "";
|
|
41
|
+
if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
42
|
+
cypressConfigFileString = fs.readFileSync(runSettings.cypressConfigFilePath).toString();
|
|
43
|
+
} else {
|
|
44
|
+
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
|
|
45
|
+
cypressConfigFileString = JSON.stringify(cypressJSON);
|
|
46
|
+
}
|
|
47
|
+
outputHash.update(cypressConfigFileString);
|
|
45
48
|
}
|
|
46
49
|
resolve(outputHash.digest(Constants.hashingOptions.encoding));
|
|
47
50
|
}).catch(function (error) {
|