browserstack-cypress-cli 1.12.1 → 1.14.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/info.js +3 -0
- package/bin/commands/runs.js +36 -0
- package/bin/helpers/archiver.js +2 -0
- package/bin/helpers/build.js +5 -1
- package/bin/helpers/buildArtifacts.js +4 -0
- package/bin/helpers/capabilityHelper.js +27 -0
- package/bin/helpers/checkUploaded.js +4 -2
- package/bin/helpers/constants.js +30 -5
- package/bin/helpers/fileHelpers.js +1 -0
- package/bin/helpers/logger.js +26 -16
- package/bin/helpers/packageInstaller.js +24 -5
- package/bin/helpers/reporterHTML.js +4 -4
- package/bin/helpers/sync/specsSummary.js +17 -1
- package/bin/helpers/sync/syncSpecsLogs.js +32 -11
- package/bin/helpers/syncRunner.js +5 -1
- package/bin/helpers/usageReporting.js +36 -7
- package/bin/helpers/utils.js +123 -1
- package/bin/helpers/zipUpload.js +18 -10
- package/bin/runner.js +29 -0
- package/bin/templates/configTemplate.js +1 -1
- package/package.json +25 -25
package/bin/commands/info.js
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
47
47
|
errorCode = 'api_failed_build_info';
|
|
48
48
|
|
|
49
49
|
logger.info(message);
|
|
50
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
50
51
|
} else {
|
|
51
52
|
let build = null;
|
|
52
53
|
try {
|
|
@@ -66,6 +67,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
66
67
|
message = Constants.userMessages.API_DEPRECATED;
|
|
67
68
|
logger.info(message);
|
|
68
69
|
}
|
|
70
|
+
logger.info(utils.formatRequest(err, resp, body));
|
|
69
71
|
} else if (resp.statusCode != 200) {
|
|
70
72
|
messageType = Constants.messageTypes.ERROR;
|
|
71
73
|
errorCode = 'api_failed_build_info';
|
|
@@ -80,6 +82,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
80
82
|
message = Constants.userMessages.BUILD_INFO_FAILED;
|
|
81
83
|
logger.error(message);
|
|
82
84
|
}
|
|
85
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
83
86
|
} else {
|
|
84
87
|
messageType = Constants.messageTypes.SUCCESS;
|
|
85
88
|
message = `Build info for build id: \n ${JSON.stringify(
|
package/bin/commands/runs.js
CHANGED
|
@@ -22,7 +22,12 @@ const archiver = require("../helpers/archiver"),
|
|
|
22
22
|
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
|
|
23
23
|
|
|
24
24
|
module.exports = function run(args, rawArgs) {
|
|
25
|
+
|
|
26
|
+
// set debug mode (--cli-debug)
|
|
27
|
+
utils.setDebugMode(args);
|
|
28
|
+
|
|
25
29
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
30
|
+
logger.debug(`browserstack.json path : ${bsConfigPath}`);
|
|
26
31
|
//Delete build_results.txt from log folder if already present.
|
|
27
32
|
initTimeComponents();
|
|
28
33
|
instrumentEventTime("cliStart")
|
|
@@ -31,9 +36,12 @@ module.exports = function run(args, rawArgs) {
|
|
|
31
36
|
markBlockEnd('deleteOldResults');
|
|
32
37
|
|
|
33
38
|
markBlockStart('validateBstackJson');
|
|
39
|
+
logger.debug('Started browserstack.json validation');
|
|
34
40
|
return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) {
|
|
35
41
|
markBlockEnd('validateBstackJson');
|
|
42
|
+
logger.debug('Completed browserstack.json validation');
|
|
36
43
|
markBlockStart('setConfig');
|
|
44
|
+
logger.debug('Started setting the configs');
|
|
37
45
|
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
|
|
38
46
|
|
|
39
47
|
utils.setDefaults(bsConfig, args);
|
|
@@ -53,6 +61,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
53
61
|
// set cypress geo location
|
|
54
62
|
utils.setGeolocation(bsConfig, args);
|
|
55
63
|
|
|
64
|
+
// set spec timeout
|
|
65
|
+
utils.setSpecTimeout(bsConfig, args);
|
|
66
|
+
|
|
56
67
|
// accept the specs list from command line if provided
|
|
57
68
|
utils.setUserSpecs(bsConfig, args);
|
|
58
69
|
|
|
@@ -80,6 +91,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
80
91
|
// set the no-wrap
|
|
81
92
|
utils.setNoWrap(bsConfig, args);
|
|
82
93
|
|
|
94
|
+
// set record feature caps
|
|
95
|
+
utils.setRecordCaps(bsConfig, args);
|
|
96
|
+
|
|
83
97
|
//set browsers
|
|
84
98
|
await utils.setBrowsers(bsConfig, args);
|
|
85
99
|
|
|
@@ -92,12 +106,16 @@ module.exports = function run(args, rawArgs) {
|
|
|
92
106
|
// set other cypress configs e.g. reporter and reporter-options
|
|
93
107
|
utils.setOtherConfigs(bsConfig, args);
|
|
94
108
|
markBlockEnd('setConfig');
|
|
109
|
+
logger.debug("Completed setting the configs");
|
|
95
110
|
|
|
96
111
|
// Validate browserstack.json values and parallels specified via arguments
|
|
97
112
|
markBlockStart('validateConfig');
|
|
113
|
+
logger.debug("Started configs validation");
|
|
98
114
|
return capabilityHelper.validate(bsConfig, args).then(function (cypressJson) {
|
|
99
115
|
markBlockEnd('validateConfig');
|
|
116
|
+
logger.debug("Completed configs validation");
|
|
100
117
|
markBlockStart('preArchiveSteps');
|
|
118
|
+
logger.debug("Started pre-archive steps");
|
|
101
119
|
//get the number of spec files
|
|
102
120
|
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
|
|
103
121
|
|
|
@@ -112,36 +130,51 @@ module.exports = function run(args, rawArgs) {
|
|
|
112
130
|
// warn if specFiles cross our limit
|
|
113
131
|
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
|
|
114
132
|
markBlockEnd('preArchiveSteps');
|
|
133
|
+
logger.debug("Completed pre-archive steps");
|
|
115
134
|
markBlockStart('zip');
|
|
135
|
+
logger.debug("Checking if test suite zip and dependencies is already available on browserstack");
|
|
116
136
|
markBlockStart('zip.checkAlreadyUploaded');
|
|
117
137
|
return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
|
|
118
138
|
markBlockEnd('zip.checkAlreadyUploaded');
|
|
139
|
+
logger.debug("Completed checking if test suite zip and dependencies already uploaded");
|
|
119
140
|
|
|
141
|
+
logger.debug("Started caching npm dependencies.");
|
|
120
142
|
markBlockStart('zip.packageInstaller');
|
|
121
143
|
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
|
|
144
|
+
logger.debug("Completed caching npm dependencies.")
|
|
122
145
|
markBlockEnd('zip.packageInstaller');
|
|
123
146
|
|
|
124
147
|
// Archive the spec files
|
|
148
|
+
logger.debug("Started archiving test suite");
|
|
125
149
|
markBlockStart('zip.archive');
|
|
126
150
|
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
|
|
151
|
+
logger.debug("Completed archiving test suite");
|
|
127
152
|
markBlockEnd('zip.archive');
|
|
128
153
|
|
|
129
154
|
let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
|
|
130
155
|
let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
|
|
131
156
|
|
|
132
157
|
// Uploaded zip file
|
|
158
|
+
logger.debug("Started uploading the test suite zip");
|
|
159
|
+
logger.debug("Started uploading the node_module zip");
|
|
133
160
|
markBlockStart('zip.zipUpload');
|
|
134
161
|
return zipUploader.zipUpload(bsConfig, md5data, packageData).then(async function (zip) {
|
|
162
|
+
logger.debug("Completed uploading the test suite zip");
|
|
163
|
+
logger.debug("Completed uploading the node_module zip");
|
|
135
164
|
markBlockEnd('zip.zipUpload');
|
|
136
165
|
markBlockEnd('zip');
|
|
137
166
|
|
|
138
167
|
// Create build
|
|
139
168
|
//setup Local Testing
|
|
140
169
|
markBlockStart('localSetup');
|
|
170
|
+
logger.debug("Started setting up BrowserStack Local connection");
|
|
141
171
|
let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
|
|
172
|
+
logger.debug('Completed setting up BrowserStack Local connection');
|
|
142
173
|
markBlockEnd('localSetup');
|
|
174
|
+
logger.debug("Started build creation");
|
|
143
175
|
markBlockStart('createBuild');
|
|
144
176
|
return build.createBuild(bsConfig, zip).then(function (data) {
|
|
177
|
+
logger.debug("Completed build creation");
|
|
145
178
|
markBlockEnd('createBuild');
|
|
146
179
|
markBlockEnd('total');
|
|
147
180
|
utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
|
|
@@ -174,7 +207,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
174
207
|
|
|
175
208
|
|
|
176
209
|
if (args.sync) {
|
|
210
|
+
logger.debug("Started polling build status from BrowserStack");
|
|
177
211
|
syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
|
|
212
|
+
logger.debug("Completed polling of build status");
|
|
178
213
|
|
|
179
214
|
// stop the Local instance
|
|
180
215
|
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
|
|
@@ -185,6 +220,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
185
220
|
// download build artifacts
|
|
186
221
|
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
|
|
187
222
|
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
223
|
+
logger.debug("Downloading build artifacts");
|
|
188
224
|
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
|
|
189
225
|
}
|
|
190
226
|
|
package/bin/helpers/archiver.js
CHANGED
|
@@ -10,6 +10,7 @@ const archiver = require("archiver"),
|
|
|
10
10
|
const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
11
11
|
return new Promise(function (resolve, reject) {
|
|
12
12
|
if (md5data.zipUrlPresent) {
|
|
13
|
+
logger.debug("Skipping test suite upload since BrowserStack already has your test suite that has not changed since the last run.");
|
|
13
14
|
return resolve('Zipping not required');
|
|
14
15
|
}
|
|
15
16
|
var output = fs.createWriteStream(filePath);
|
|
@@ -55,6 +56,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
55
56
|
archive.pipe(output);
|
|
56
57
|
|
|
57
58
|
let ignoreFiles = utils.getFilesToIgnore(runSettings, excludeFiles);
|
|
59
|
+
logger.debug(`Patterns ignored during zip ${ignoreFiles}`);
|
|
58
60
|
archive.glob(`**/*.+(${Constants.allowedFileTypes.join("|")})`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
|
|
59
61
|
|
|
60
62
|
let packageJSON = {};
|
package/bin/helpers/build.js
CHANGED
|
@@ -4,7 +4,8 @@ const request = require('request');
|
|
|
4
4
|
const config = require('./config'),
|
|
5
5
|
capabilityHelper = require("../helpers/capabilityHelper"),
|
|
6
6
|
Constants = require('../helpers/constants'),
|
|
7
|
-
utils = require('../helpers/utils')
|
|
7
|
+
utils = require('../helpers/utils'),
|
|
8
|
+
logger = require('../helpers/logger').winstonLogger;
|
|
8
9
|
|
|
9
10
|
const createBuild = (bsConfig, zip) => {
|
|
10
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -24,6 +25,7 @@ const createBuild = (bsConfig, zip) => {
|
|
|
24
25
|
|
|
25
26
|
request.post(options, function (err, resp, body) {
|
|
26
27
|
if (err) {
|
|
28
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
27
29
|
reject(err);
|
|
28
30
|
} else {
|
|
29
31
|
let build = null;
|
|
@@ -37,9 +39,11 @@ const createBuild = (bsConfig, zip) => {
|
|
|
37
39
|
if (build) {
|
|
38
40
|
resolve(build.message);
|
|
39
41
|
} else {
|
|
42
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
40
43
|
reject(Constants.userMessages.API_DEPRECATED);
|
|
41
44
|
}
|
|
42
45
|
} else if (resp.statusCode != 201) {
|
|
46
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
43
47
|
if (build) {
|
|
44
48
|
reject(`${Constants.userMessages.BUILD_FAILED} Error: ${build.message}`);
|
|
45
49
|
} else {
|
|
@@ -162,6 +162,7 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
|
|
|
162
162
|
request.post(options, function (err, resp, data) {
|
|
163
163
|
if(err) {
|
|
164
164
|
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
|
|
165
|
+
logger.error(utils.formatRequest(err, resp, data));
|
|
165
166
|
reject(err);
|
|
166
167
|
} else {
|
|
167
168
|
try {
|
|
@@ -203,6 +204,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
203
204
|
let buildDetails = null;
|
|
204
205
|
request.get(options, async function (err, resp, body) {
|
|
205
206
|
if(err) {
|
|
207
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
206
208
|
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
207
209
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
208
210
|
} else {
|
|
@@ -211,6 +213,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
211
213
|
if(resp.statusCode != 200) {
|
|
212
214
|
logger.error('Downloading the build artifacts failed.');
|
|
213
215
|
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
216
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
214
217
|
utils.sendUsageReport(bsConfig, args, buildDetails, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
215
218
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
216
219
|
} else {
|
|
@@ -241,6 +244,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
241
244
|
}
|
|
242
245
|
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, null, rawArgs);
|
|
243
246
|
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
247
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
244
248
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
245
249
|
}
|
|
246
250
|
}
|
|
@@ -146,6 +146,7 @@ const addCypressZipStartLocation = (runSettings) => {
|
|
|
146
146
|
let resolvedCypressConfigFilePath = path.resolve(runSettings.cypressConfigFilePath);
|
|
147
147
|
runSettings.cypressZipStartLocation = path.dirname(resolvedCypressConfigFilePath.split(resolvedHomeDirectoryPath)[1]);
|
|
148
148
|
runSettings.cypressZipStartLocation = runSettings.cypressZipStartLocation.substring(1);
|
|
149
|
+
logger.debug(`Setting cypress zip start location = ${runSettings.cypressZipStartLocation}`);
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
const validate = (bsConfig, args) => {
|
|
@@ -190,8 +191,10 @@ const validate = (bsConfig, args) => {
|
|
|
190
191
|
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
|
|
191
192
|
let cypressJson = {};
|
|
192
193
|
|
|
194
|
+
logger.debug(`Checking for cypress config file at ${cypressConfigFilePath}`);
|
|
193
195
|
if (!fs.existsSync(cypressConfigFilePath) && bsConfig.run_settings.cypress_config_filename !== 'false') reject(Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE);
|
|
194
196
|
|
|
197
|
+
logger.debug("Validating cypress.json");
|
|
195
198
|
try {
|
|
196
199
|
if (bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
197
200
|
let cypressJsonContent = fs.readFileSync(cypressConfigFilePath);
|
|
@@ -210,6 +213,7 @@ const validate = (bsConfig, args) => {
|
|
|
210
213
|
//check if home_directory is present or not in user run_settings
|
|
211
214
|
if (!Utils.isUndefined(bsConfig.run_settings.home_directory)) {
|
|
212
215
|
// check if home_directory exists or not
|
|
216
|
+
logger.debug(`Validating home_directory at ${bsConfig.run_settings.home_directory}`);
|
|
213
217
|
if (!fs.existsSync(bsConfig.run_settings.home_directory)) {
|
|
214
218
|
reject(Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND);
|
|
215
219
|
}
|
|
@@ -227,6 +231,29 @@ const validate = (bsConfig, args) => {
|
|
|
227
231
|
addCypressZipStartLocation(bsConfig.run_settings);
|
|
228
232
|
}
|
|
229
233
|
|
|
234
|
+
if(!Utils.isUndefined(bsConfig.run_settings.spec_timeout)) {
|
|
235
|
+
if(Utils.isPositiveInteger(bsConfig.run_settings.spec_timeout.toString().trim())) {
|
|
236
|
+
if(Number(bsConfig.run_settings.spec_timeout) > Constants.SPEC_TIMEOUT_LIMIT) {
|
|
237
|
+
reject(Constants.validationMessages.SPEC_TIMEOUT_LIMIT_ERROR)
|
|
238
|
+
} else {
|
|
239
|
+
logger.info(Constants.userMessages.SPEC_LIMIT_SUCCESS_MESSAGE.replace("<x>", bsConfig.run_settings.spec_timeout));
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
logger.warn(Constants.userMessages.SPEC_TIMEOUT_LIMIT_WARNING)
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
logger.warn(Constants.validationMessages.SPEC_TIMEOUT_NOT_PASSED_ERROR);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if(!Utils.isUndefined(bsConfig.run_settings["record"]) && String(bsConfig.run_settings["record"]) == 'true') {
|
|
249
|
+
if(Utils.isUndefined(bsConfig.run_settings.projectId) || bsConfig.run_settings.projectId == "" ) {
|
|
250
|
+
logger.warn(Constants.validationMessages.PROJECT_ID_MISSING);
|
|
251
|
+
}
|
|
252
|
+
if (Utils.isUndefined(bsConfig.run_settings["record-key"]) || bsConfig.run_settings["record-key"] == "" ) {
|
|
253
|
+
logger.warn(Constants.validationMessages.RECORD_KEY_MISSING);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
230
257
|
resolve(cypressJson);
|
|
231
258
|
});
|
|
232
259
|
}
|
|
@@ -7,7 +7,8 @@ const crypto = require('crypto'),
|
|
|
7
7
|
config = require('./config'),
|
|
8
8
|
path = require('path'),
|
|
9
9
|
fs = require("fs"),
|
|
10
|
-
utils = require('./utils')
|
|
10
|
+
utils = require('./utils'),
|
|
11
|
+
logger = require('./logger').winstonLogger;
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
@@ -82,7 +83,8 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
82
83
|
zipUrlPresent: false,
|
|
83
84
|
packageUrlPresent: false,
|
|
84
85
|
};
|
|
85
|
-
if (args["force-upload"]
|
|
86
|
+
if (args["force-upload"]) {
|
|
87
|
+
logger.debug("force-upload set to true. Uploading tests and npm packages.");
|
|
86
88
|
return resolve(obj);
|
|
87
89
|
}
|
|
88
90
|
|
package/bin/helpers/constants.js
CHANGED
|
@@ -21,6 +21,7 @@ const userMessages = {
|
|
|
21
21
|
ZIP_UPLOADER_NOT_REACHABLE: "Could not reach BrowserStack APIs. Please check your network or see if you need to whitelist *.browserstack.com",
|
|
22
22
|
ZIP_UPLOAD_FAILED: "Zip Upload failed.",
|
|
23
23
|
ZIP_UPLOAD_LIMIT_EXCEEDED: "The directory size which contains the cypress config file is more than 200 MB. For more info, check out https://www.browserstack.com/docs/automate/cypress/exclude-files",
|
|
24
|
+
NODE_MODULES_LIMIT_EXCEEDED: "node_modules upload failed as the size %SIZE% MB is not supported. Dependencies will be installed in runtime. This will have a negative impact on build performance. Reach out to us at browserstack.com/support if you see this warning.",
|
|
24
25
|
CONFIG_FILE_CREATED: "BrowserStack Config File created, you can now run browserstack-cypress --config-file run",
|
|
25
26
|
CONFIG_FILE_EXISTS: "File already exists, delete the browserstack.json file manually. skipping...",
|
|
26
27
|
DIR_NOT_FOUND: "Given path does not exist. Failed to create browserstack.json in %s",
|
|
@@ -63,7 +64,9 @@ const userMessages = {
|
|
|
63
64
|
DOWNLOAD_BUILD_ARTIFACTS_SUCCESS: "Your build artifact(s) have been successfully downloaded in '<user-path>/build_artifacts/<build-id>' directory",
|
|
64
65
|
LATEST_SYNTAX_TO_ACTUAL_VERSION_MESSAGE: "Your build will run using Cypress <actualVersion> as you had specified <latestSyntaxVersion>.<frameworkUpgradeMessage> Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions",
|
|
65
66
|
PROCESS_KILL_MESSAGE: "Stopping the CLI and the execution of the build on BrowserStack",
|
|
66
|
-
BUILD_FAILED_ERROR: "The above stacktrace has been thrown by Cypress when we tried to run your build. If your test suite requires npm dependencies then please specify them on browserstack.json. Read more at " + chalk.blueBright("https://www.browserstack.com/docs/automate/cypress/npm-packages") + ". Also, we recommend you to try running the build locally using ‘cypress run’ and if it works fine then please reach out to support at " + chalk.blueBright("https://www.browserstack.com/contact#technical-support")
|
|
67
|
+
BUILD_FAILED_ERROR: "The above stacktrace has been thrown by Cypress when we tried to run your build. If your test suite requires npm dependencies then please specify them on browserstack.json. Read more at " + chalk.blueBright("https://www.browserstack.com/docs/automate/cypress/npm-packages") + ". Also, we recommend you to try running the build locally using ‘cypress run’ and if it works fine then please reach out to support at " + chalk.blueBright("https://www.browserstack.com/contact#technical-support"),
|
|
68
|
+
SPEC_TIMEOUT_LIMIT_WARNING: "Value for the 'spec_timeout' key not in the 1-120 range. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout",
|
|
69
|
+
SPEC_LIMIT_SUCCESS_MESSAGE: "Spec timeout specified as <x> minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack"
|
|
67
70
|
};
|
|
68
71
|
|
|
69
72
|
const validationMessages = {
|
|
@@ -97,7 +100,11 @@ const validationMessages = {
|
|
|
97
100
|
NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE: "IP Geolocation feature is not available in conjunction with BrowserStack Local.",
|
|
98
101
|
HOME_DIRECTORY_NOT_FOUND: "Specified home directory could not be found. Please make sure the path of the home directory is correct.",
|
|
99
102
|
HOME_DIRECTORY_NOT_A_DIRECTORY: "Specified home directory is not a directory. The home directory can only be a directory and not a file.",
|
|
100
|
-
CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY: "Could not find cypress.json within the specified home directory. Please make sure cypress.json resides within the home directory."
|
|
103
|
+
CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY: "Could not find cypress.json within the specified home directory. Please make sure cypress.json resides within the home directory.",
|
|
104
|
+
SPEC_TIMEOUT_LIMIT_ERROR: "The maximum allowed value of 'spec_timeout' is 120. Read more on https://browserstack.com/docs/automate/cypress/spec-timeout ",
|
|
105
|
+
SPEC_TIMEOUT_NOT_PASSED_ERROR: "'spec_timeout' key not specified. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout ",
|
|
106
|
+
PROJECT_ID_MISSING: "You have specified '--record' flag but you've not provided the 'projectId' in cypress.json or in browserstack.json. Your record functionality on cypress.io dashboard might not work as it needs both the key and the projectId",
|
|
107
|
+
RECORD_KEY_MISSING: "You have specified '--record' flag but you've not provided the '--record-key' and we could not find any value in 'CYPRESS_RECORD_KEY' environment variable. Your record functionality on cypress.io dashboard might not work as it needs the key and projectId"
|
|
101
108
|
};
|
|
102
109
|
|
|
103
110
|
const cliMessages = {
|
|
@@ -140,7 +147,11 @@ const cliMessages = {
|
|
|
140
147
|
CONFIG_DESCRIPTION: "Set configuration values. Separate multiple values with a comma. The values set here override any values set in your configuration file.",
|
|
141
148
|
REPORTER: "Specify the custom reporter to use",
|
|
142
149
|
REPORTER_OPTIONS: "Specify reporter options for custom reporter",
|
|
143
|
-
CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations."
|
|
150
|
+
CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations.",
|
|
151
|
+
SPEC_TIMEOUT: "Specify a value for a hard timeout for each spec execution in the 1-120 mins range. Read https://browserstack.com/docs/automate/cypress/spec-timeout for more details.",
|
|
152
|
+
RECORD: "Pass the --record flag to record your Cypress runs on Cypress.io dashboard. Note: You also need to specify '--record-key' and '--projectId' arguments either in CLI or in browserstack.json.",
|
|
153
|
+
RECORD_KEY: "You can specify the 'key' that is needed to record your runs on Cypress.io dashboard using the '--record-key' argument. Alternatively, you can also pass it on browserstack.json",
|
|
154
|
+
PROJECT_ID: "You can pass the 'projectId' of your Cypress.io project where you want to record your runs if specifying the '--record' key. You can also specify this in your cypress.json or in your browserstack.json."
|
|
144
155
|
},
|
|
145
156
|
COMMON: {
|
|
146
157
|
DISABLE_USAGE_REPORTING: "Disable usage reporting",
|
|
@@ -150,6 +161,7 @@ const cliMessages = {
|
|
|
150
161
|
NO_NPM_WARNING: "No NPM warning if npm_dependencies is empty",
|
|
151
162
|
CONFIG_DEMAND: "config file is required",
|
|
152
163
|
CONFIG_FILE_PATH: "Path to BrowserStack config",
|
|
164
|
+
DEBUG: "Use this option to get debug logs on the CLI console.",
|
|
153
165
|
},
|
|
154
166
|
GENERATE_REPORT: {
|
|
155
167
|
INFO: "Generates the build report"
|
|
@@ -168,7 +180,7 @@ const messageTypes = {
|
|
|
168
180
|
NULL: null
|
|
169
181
|
}
|
|
170
182
|
|
|
171
|
-
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc', 'xml', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'jsx', 'coffee', 'cjsx', 'csv', 'tsv', 'yml', 'yaml', 'env', 'mov', 'mp4', 'mp3', 'wav'];
|
|
183
|
+
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc', 'xml', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'jsx', 'coffee', 'cjsx', 'csv', 'tsv', 'yml', 'yaml', 'env', 'mov', 'mp4', 'mp3', 'wav', 'gz', 'tgz', 'tiff', 'bmp', 'msg', 'gif', 'sql'];
|
|
172
184
|
|
|
173
185
|
const filesToIgnoreWhileUploading = [
|
|
174
186
|
'**/node_modules/**',
|
|
@@ -226,6 +238,10 @@ const LATEST_VERSION_SYNTAX_REGEX = /\d*.latest(.\d*)?/gm
|
|
|
226
238
|
|
|
227
239
|
const AUTH_REGEX = /"auth" *: *{[\s\S]*?}/g
|
|
228
240
|
|
|
241
|
+
const CLI_ARGS_REGEX = /(?<=("u"|"username"|"k"|"key") *: *)"[^,}]*/g
|
|
242
|
+
|
|
243
|
+
const RAW_ARGS_REGEX = /(?<=("-u"|"-username"|"-k"|"-key") *, *)"[^,\]]*/g
|
|
244
|
+
|
|
229
245
|
const ERROR_EXIT_CODE = 1;
|
|
230
246
|
|
|
231
247
|
const BUILD_FAILED_EXIT_CODE = 3;
|
|
@@ -234,6 +250,10 @@ const REDACTED = "[REDACTED]";
|
|
|
234
250
|
|
|
235
251
|
const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED} }`;
|
|
236
252
|
|
|
253
|
+
const SPEC_TIMEOUT_LIMIT = 120 // IN MINS
|
|
254
|
+
|
|
255
|
+
const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
|
|
256
|
+
|
|
237
257
|
module.exports = Object.freeze({
|
|
238
258
|
syncCLI,
|
|
239
259
|
userMessages,
|
|
@@ -253,6 +273,11 @@ module.exports = Object.freeze({
|
|
|
253
273
|
LATEST_VERSION_SYNTAX_REGEX,
|
|
254
274
|
ERROR_EXIT_CODE,
|
|
255
275
|
AUTH_REGEX,
|
|
276
|
+
CLI_ARGS_REGEX,
|
|
277
|
+
RAW_ARGS_REGEX,
|
|
256
278
|
REDACTED_AUTH,
|
|
257
|
-
|
|
279
|
+
REDACTED,
|
|
280
|
+
BUILD_FAILED_EXIT_CODE,
|
|
281
|
+
SPEC_TIMEOUT_LIMIT,
|
|
282
|
+
CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY
|
|
258
283
|
});
|
package/bin/helpers/logger.js
CHANGED
|
@@ -8,37 +8,47 @@ if (!fs.existsSync(logDir)) {
|
|
|
8
8
|
fs.mkdirSync(logDir);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
// Save transports to change log level dynamically
|
|
12
|
+
const transports = {
|
|
13
|
+
loggerConsole: new winston.transports.Console({
|
|
14
|
+
name: 'console.info',
|
|
15
|
+
colorize: true,
|
|
16
|
+
timestamp: function () {
|
|
17
|
+
return `[${new Date().toLocaleString()}]`;
|
|
18
|
+
},
|
|
19
|
+
prettyPrint: true,
|
|
20
|
+
}),
|
|
21
|
+
syncLoggerConsole: new (winston.transports.Console)({
|
|
22
|
+
formatter: (options) => {
|
|
23
|
+
return (options.message ? options.message : '');
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
loggerFile: new winston.transports.File({
|
|
27
|
+
filename: path.join(logDir, "/usage.log"),
|
|
28
|
+
}),
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
const winstonLoggerParams = {
|
|
12
32
|
transports: [
|
|
13
|
-
|
|
14
|
-
name: 'console.info',
|
|
15
|
-
colorize: true,
|
|
16
|
-
timestamp: function () {
|
|
17
|
-
return `[${new Date().toLocaleString()}]`;
|
|
18
|
-
},
|
|
19
|
-
prettyPrint: true,
|
|
20
|
-
}),
|
|
33
|
+
transports.loggerConsole,
|
|
21
34
|
],
|
|
22
35
|
};
|
|
23
36
|
|
|
24
37
|
const winstonSyncCliLoggerParams = {
|
|
25
38
|
transports: [
|
|
26
|
-
|
|
27
|
-
formatter: (options) => {
|
|
28
|
-
return (options.message ? options.message : '');
|
|
29
|
-
}
|
|
30
|
-
}),
|
|
39
|
+
transports.syncLoggerConsole,
|
|
31
40
|
]
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
const winstonFileLoggerParams = {
|
|
35
44
|
transports: [
|
|
36
|
-
|
|
37
|
-
filename: path.join(logDir, "/usage.log"),
|
|
38
|
-
}),
|
|
45
|
+
transports.loggerFile,
|
|
39
46
|
],
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
exports.winstonLogger = new winston.Logger(winstonLoggerParams);
|
|
43
50
|
exports.fileLogger = new winston.Logger(winstonFileLoggerParams);
|
|
44
51
|
exports.syncCliLogger = new winston.Logger(winstonSyncCliLoggerParams);
|
|
52
|
+
|
|
53
|
+
//Export transports to change log level
|
|
54
|
+
exports.transports = transports;
|
|
@@ -7,18 +7,21 @@
|
|
|
7
7
|
Constants = require('./constants'),
|
|
8
8
|
process = require('process'),
|
|
9
9
|
utils = require('./utils'),
|
|
10
|
-
{ spawn } = require('child_process')
|
|
10
|
+
{ spawn } = require('child_process'),
|
|
11
|
+
util = require('util');
|
|
11
12
|
|
|
12
13
|
let nodeProcess;
|
|
13
14
|
|
|
14
15
|
const setupPackageFolder = (runSettings, directoryPath) => {
|
|
15
16
|
return new Promise(function (resolve, reject) {
|
|
16
17
|
fileHelpers.deletePackageArchieve(false);
|
|
18
|
+
logger.debug(`Started creating ${directoryPath} folder`);
|
|
17
19
|
fs.mkdir(directoryPath, function (err) {
|
|
18
20
|
try {
|
|
19
21
|
if (err) {
|
|
20
22
|
return reject(err);
|
|
21
23
|
}
|
|
24
|
+
logger.debug(`Completed creating ${directoryPath}`);
|
|
22
25
|
let packageJSON = {};
|
|
23
26
|
if (typeof runSettings.package_config_options === 'object') {
|
|
24
27
|
Object.assign(packageJSON, runSettings.package_config_options);
|
|
@@ -38,12 +41,16 @@ const setupPackageFolder = (runSettings, directoryPath) => {
|
|
|
38
41
|
let sourceNpmrc = path.join(cypressFolderPath, ".npmrc");
|
|
39
42
|
let destNpmrc = path.join(directoryPath, ".npmrc");
|
|
40
43
|
if (fs.existsSync(sourceNpmrc)) {
|
|
44
|
+
logger.debug(`Copying .npmrc file from ${sourceNpmrc} to ${destNpmrc}`);
|
|
41
45
|
fs.copyFileSync(sourceNpmrc, destNpmrc);
|
|
42
46
|
}
|
|
47
|
+
logger.debug(`${packagePath} file created with ${packageJSONString}`);
|
|
43
48
|
return resolve("Package file created");
|
|
44
49
|
}
|
|
50
|
+
logger.debug("Nothing in package file");
|
|
45
51
|
return reject("Nothing in package file");
|
|
46
52
|
} catch(error) {
|
|
53
|
+
logger.debug(`Creating ${directoryPath} failed with error ${error}`);
|
|
47
54
|
return reject(error);
|
|
48
55
|
}
|
|
49
56
|
})
|
|
@@ -54,16 +61,18 @@ const packageInstall = (packageDir) => {
|
|
|
54
61
|
return new Promise(function (resolve, reject) {
|
|
55
62
|
const nodeProcessCloseCallback = (code) => {
|
|
56
63
|
if(code == 0) {
|
|
64
|
+
logger.info(`Packages were installed locally successfully.`);
|
|
57
65
|
resolve('Packages were installed successfully.');
|
|
58
66
|
} else {
|
|
59
|
-
|
|
67
|
+
logger.error(`Some error occurred while installing packages. Error code ${code}`);
|
|
68
|
+
reject(`Packages were not installed successfully. Error code ${code}`);
|
|
60
69
|
}
|
|
61
70
|
};
|
|
62
71
|
const nodeProcessErrorCallback = (error) => {
|
|
63
|
-
logger.error(`Some error occurred while installing packages:
|
|
64
|
-
reject(`Packages were not installed successfully
|
|
72
|
+
logger.error(`Some error occurred while installing packages: %j`, error);
|
|
73
|
+
reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`);
|
|
65
74
|
};
|
|
66
|
-
nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install'], {cwd: packageDir});
|
|
75
|
+
nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install', '--loglevel', 'verbose', '>', '../npm_install_debug.log', '2>&1'], {cwd: packageDir, shell: true});
|
|
67
76
|
nodeProcess.on('close', nodeProcessCloseCallback);
|
|
68
77
|
nodeProcess.on('error', nodeProcessErrorCallback);
|
|
69
78
|
});
|
|
@@ -79,6 +88,7 @@ const packageArchiver = (packageDir, packageFile) => {
|
|
|
79
88
|
if (err.code === 'ENOENT') {
|
|
80
89
|
logger.info(err);
|
|
81
90
|
} else {
|
|
91
|
+
logger.debug(`Archiving of node_modules failed with error ${err}`);
|
|
82
92
|
reject(err);
|
|
83
93
|
}
|
|
84
94
|
});
|
|
@@ -92,6 +102,7 @@ const packageArchiver = (packageDir, packageFile) => {
|
|
|
92
102
|
});
|
|
93
103
|
|
|
94
104
|
archive.on('error', function (err) {
|
|
105
|
+
logger.debug(`Archiving of node_modules failed with error ${err}`);
|
|
95
106
|
reject(err);
|
|
96
107
|
});
|
|
97
108
|
|
|
@@ -107,24 +118,32 @@ const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBl
|
|
|
107
118
|
packageArchieveCreated: false
|
|
108
119
|
};
|
|
109
120
|
if (md5data.packageUrlPresent || !utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
|
|
121
|
+
logger.debug("Skipping the caching of npm packages since BrowserStack has already cached your npm dependencies that have not changed since the last run.")
|
|
110
122
|
return resolve(obj);
|
|
111
123
|
}
|
|
112
124
|
logger.info(Constants.userMessages.NPM_INSTALL_AND_UPLOAD);
|
|
113
125
|
instrumentBlocks.markBlockStart("packageInstaller.folderSetup");
|
|
126
|
+
logger.debug("Started setting up package folder");
|
|
114
127
|
return setupPackageFolder(bsConfig.run_settings, packageDir).then((_result) => {
|
|
128
|
+
logger.debug("Completed setting up package folder");
|
|
115
129
|
process.env.CYPRESS_INSTALL_BINARY = 0
|
|
116
130
|
instrumentBlocks.markBlockEnd("packageInstaller.folderSetup");
|
|
117
131
|
instrumentBlocks.markBlockStart("packageInstaller.packageInstall");
|
|
132
|
+
logger.debug("Started installing dependencies specified in browserstack.json");
|
|
118
133
|
return packageInstall(packageDir);
|
|
119
134
|
}).then((_result) => {
|
|
135
|
+
logger.debug("Completed installing dependencies");
|
|
120
136
|
instrumentBlocks.markBlockEnd("packageInstaller.packageInstall");
|
|
121
137
|
instrumentBlocks.markBlockStart("packageInstaller.packageArchive");
|
|
138
|
+
logger.debug("Started archiving node_modules")
|
|
122
139
|
return packageArchiver(packageDir, packageFile);
|
|
123
140
|
}).then((_result) => {
|
|
141
|
+
logger.debug("Archiving of node_modules completed");
|
|
124
142
|
instrumentBlocks.markBlockEnd("packageInstaller.packageArchive");
|
|
125
143
|
Object.assign(obj, { packageArchieveCreated: true });
|
|
126
144
|
return resolve(obj);
|
|
127
145
|
}).catch((err) => {
|
|
146
|
+
logger.warn(`Error occured while caching npm dependencies. Dependencies will be installed in runtime. This will have a negative impact on performance. Reach out to browserstack.com/contact, if you persistantly face this issue.`);
|
|
128
147
|
obj.error = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
|
|
129
148
|
return resolve(obj);
|
|
130
149
|
})
|
|
@@ -105,14 +105,14 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
105
105
|
let messageType = null;
|
|
106
106
|
let errorCode = null;
|
|
107
107
|
let build;
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
if (err) {
|
|
110
110
|
message = err;
|
|
111
111
|
messageType = Constants.messageTypes.ERROR;
|
|
112
112
|
errorCode = 'api_failed_build_report';
|
|
113
113
|
|
|
114
114
|
logger.error('Generating the build report failed.');
|
|
115
|
-
logger.error(
|
|
115
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
116
116
|
|
|
117
117
|
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
|
|
118
118
|
return;
|
|
@@ -145,7 +145,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
145
145
|
logger.error(`Error generating the report: ${error}`);
|
|
146
146
|
response = {message: message};
|
|
147
147
|
}
|
|
148
|
-
logger.error(
|
|
148
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
149
149
|
} else if (resp.statusCode != 200) {
|
|
150
150
|
messageType = Constants.messageTypes.ERROR;
|
|
151
151
|
errorCode = 'api_failed_build_generate_report';
|
|
@@ -158,7 +158,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
158
158
|
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
159
159
|
} else {
|
|
160
160
|
message = Constants.userMessages.BUILD_GENERATE_REPORT_FAILED.replace('<build-id>', buildId);
|
|
161
|
-
logger.error(
|
|
161
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
162
162
|
}
|
|
163
163
|
} else {
|
|
164
164
|
messageType = Constants.messageTypes.SUCCESS;
|