browserstack-cypress-cli 1.13.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/runs.js +33 -0
- package/bin/helpers/archiver.js +2 -0
- package/bin/helpers/buildArtifacts.js +1 -1
- package/bin/helpers/capabilityHelper.js +13 -0
- package/bin/helpers/checkUploaded.js +3 -1
- package/bin/helpers/constants.js +13 -3
- package/bin/helpers/fileHelpers.js +1 -0
- package/bin/helpers/logger.js +26 -16
- package/bin/helpers/packageInstaller.js +19 -3
- 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 +25 -2
- package/bin/helpers/utils.js +81 -1
- package/bin/helpers/zipUpload.js +8 -1
- package/bin/runner.js +23 -0
- package/package.json +1 -1
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);
|
|
@@ -83,6 +91,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
83
91
|
// set the no-wrap
|
|
84
92
|
utils.setNoWrap(bsConfig, args);
|
|
85
93
|
|
|
94
|
+
// set record feature caps
|
|
95
|
+
utils.setRecordCaps(bsConfig, args);
|
|
96
|
+
|
|
86
97
|
//set browsers
|
|
87
98
|
await utils.setBrowsers(bsConfig, args);
|
|
88
99
|
|
|
@@ -95,12 +106,16 @@ module.exports = function run(args, rawArgs) {
|
|
|
95
106
|
// set other cypress configs e.g. reporter and reporter-options
|
|
96
107
|
utils.setOtherConfigs(bsConfig, args);
|
|
97
108
|
markBlockEnd('setConfig');
|
|
109
|
+
logger.debug("Completed setting the configs");
|
|
98
110
|
|
|
99
111
|
// Validate browserstack.json values and parallels specified via arguments
|
|
100
112
|
markBlockStart('validateConfig');
|
|
113
|
+
logger.debug("Started configs validation");
|
|
101
114
|
return capabilityHelper.validate(bsConfig, args).then(function (cypressJson) {
|
|
102
115
|
markBlockEnd('validateConfig');
|
|
116
|
+
logger.debug("Completed configs validation");
|
|
103
117
|
markBlockStart('preArchiveSteps');
|
|
118
|
+
logger.debug("Started pre-archive steps");
|
|
104
119
|
//get the number of spec files
|
|
105
120
|
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
|
|
106
121
|
|
|
@@ -115,36 +130,51 @@ module.exports = function run(args, rawArgs) {
|
|
|
115
130
|
// warn if specFiles cross our limit
|
|
116
131
|
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
|
|
117
132
|
markBlockEnd('preArchiveSteps');
|
|
133
|
+
logger.debug("Completed pre-archive steps");
|
|
118
134
|
markBlockStart('zip');
|
|
135
|
+
logger.debug("Checking if test suite zip and dependencies is already available on browserstack");
|
|
119
136
|
markBlockStart('zip.checkAlreadyUploaded');
|
|
120
137
|
return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
|
|
121
138
|
markBlockEnd('zip.checkAlreadyUploaded');
|
|
139
|
+
logger.debug("Completed checking if test suite zip and dependencies already uploaded");
|
|
122
140
|
|
|
141
|
+
logger.debug("Started caching npm dependencies.");
|
|
123
142
|
markBlockStart('zip.packageInstaller');
|
|
124
143
|
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
|
|
144
|
+
logger.debug("Completed caching npm dependencies.")
|
|
125
145
|
markBlockEnd('zip.packageInstaller');
|
|
126
146
|
|
|
127
147
|
// Archive the spec files
|
|
148
|
+
logger.debug("Started archiving test suite");
|
|
128
149
|
markBlockStart('zip.archive');
|
|
129
150
|
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
|
|
151
|
+
logger.debug("Completed archiving test suite");
|
|
130
152
|
markBlockEnd('zip.archive');
|
|
131
153
|
|
|
132
154
|
let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
|
|
133
155
|
let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
|
|
134
156
|
|
|
135
157
|
// Uploaded zip file
|
|
158
|
+
logger.debug("Started uploading the test suite zip");
|
|
159
|
+
logger.debug("Started uploading the node_module zip");
|
|
136
160
|
markBlockStart('zip.zipUpload');
|
|
137
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");
|
|
138
164
|
markBlockEnd('zip.zipUpload');
|
|
139
165
|
markBlockEnd('zip');
|
|
140
166
|
|
|
141
167
|
// Create build
|
|
142
168
|
//setup Local Testing
|
|
143
169
|
markBlockStart('localSetup');
|
|
170
|
+
logger.debug("Started setting up BrowserStack Local connection");
|
|
144
171
|
let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
|
|
172
|
+
logger.debug('Completed setting up BrowserStack Local connection');
|
|
145
173
|
markBlockEnd('localSetup');
|
|
174
|
+
logger.debug("Started build creation");
|
|
146
175
|
markBlockStart('createBuild');
|
|
147
176
|
return build.createBuild(bsConfig, zip).then(function (data) {
|
|
177
|
+
logger.debug("Completed build creation");
|
|
148
178
|
markBlockEnd('createBuild');
|
|
149
179
|
markBlockEnd('total');
|
|
150
180
|
utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
|
|
@@ -177,7 +207,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
177
207
|
|
|
178
208
|
|
|
179
209
|
if (args.sync) {
|
|
210
|
+
logger.debug("Started polling build status from BrowserStack");
|
|
180
211
|
syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
|
|
212
|
+
logger.debug("Completed polling of build status");
|
|
181
213
|
|
|
182
214
|
// stop the Local instance
|
|
183
215
|
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
|
|
@@ -188,6 +220,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
188
220
|
// download build artifacts
|
|
189
221
|
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
|
|
190
222
|
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
223
|
+
logger.debug("Downloading build artifacts");
|
|
191
224
|
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
|
|
192
225
|
}
|
|
193
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 = {};
|
|
@@ -162,7 +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,
|
|
165
|
+
logger.error(utils.formatRequest(err, resp, data));
|
|
166
166
|
reject(err);
|
|
167
167
|
} else {
|
|
168
168
|
try {
|
|
@@ -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
|
}
|
|
@@ -241,6 +245,15 @@ const validate = (bsConfig, args) => {
|
|
|
241
245
|
logger.warn(Constants.validationMessages.SPEC_TIMEOUT_NOT_PASSED_ERROR);
|
|
242
246
|
}
|
|
243
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
|
+
|
|
244
257
|
resolve(cypressJson);
|
|
245
258
|
});
|
|
246
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) => {
|
|
@@ -83,6 +84,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
83
84
|
packageUrlPresent: false,
|
|
84
85
|
};
|
|
85
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",
|
|
@@ -101,7 +102,9 @@ const validationMessages = {
|
|
|
101
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.",
|
|
102
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.",
|
|
103
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 ",
|
|
104
|
-
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 "
|
|
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"
|
|
105
108
|
};
|
|
106
109
|
|
|
107
110
|
const cliMessages = {
|
|
@@ -145,7 +148,10 @@ const cliMessages = {
|
|
|
145
148
|
REPORTER: "Specify the custom reporter to use",
|
|
146
149
|
REPORTER_OPTIONS: "Specify reporter options for custom reporter",
|
|
147
150
|
CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations.",
|
|
148
|
-
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."
|
|
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."
|
|
149
155
|
},
|
|
150
156
|
COMMON: {
|
|
151
157
|
DISABLE_USAGE_REPORTING: "Disable usage reporting",
|
|
@@ -155,6 +161,7 @@ const cliMessages = {
|
|
|
155
161
|
NO_NPM_WARNING: "No NPM warning if npm_dependencies is empty",
|
|
156
162
|
CONFIG_DEMAND: "config file is required",
|
|
157
163
|
CONFIG_FILE_PATH: "Path to BrowserStack config",
|
|
164
|
+
DEBUG: "Use this option to get debug logs on the CLI console.",
|
|
158
165
|
},
|
|
159
166
|
GENERATE_REPORT: {
|
|
160
167
|
INFO: "Generates the build report"
|
|
@@ -245,6 +252,8 @@ const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED}
|
|
|
245
252
|
|
|
246
253
|
const SPEC_TIMEOUT_LIMIT = 120 // IN MINS
|
|
247
254
|
|
|
255
|
+
const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
|
|
256
|
+
|
|
248
257
|
module.exports = Object.freeze({
|
|
249
258
|
syncCLI,
|
|
250
259
|
userMessages,
|
|
@@ -269,5 +278,6 @@ module.exports = Object.freeze({
|
|
|
269
278
|
REDACTED_AUTH,
|
|
270
279
|
REDACTED,
|
|
271
280
|
BUILD_FAILED_EXIT_CODE,
|
|
272
|
-
SPEC_TIMEOUT_LIMIT
|
|
281
|
+
SPEC_TIMEOUT_LIMIT,
|
|
282
|
+
CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY
|
|
273
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;
|
|
@@ -15,11 +15,13 @@ let nodeProcess;
|
|
|
15
15
|
const setupPackageFolder = (runSettings, directoryPath) => {
|
|
16
16
|
return new Promise(function (resolve, reject) {
|
|
17
17
|
fileHelpers.deletePackageArchieve(false);
|
|
18
|
+
logger.debug(`Started creating ${directoryPath} folder`);
|
|
18
19
|
fs.mkdir(directoryPath, function (err) {
|
|
19
20
|
try {
|
|
20
21
|
if (err) {
|
|
21
22
|
return reject(err);
|
|
22
23
|
}
|
|
24
|
+
logger.debug(`Completed creating ${directoryPath}`);
|
|
23
25
|
let packageJSON = {};
|
|
24
26
|
if (typeof runSettings.package_config_options === 'object') {
|
|
25
27
|
Object.assign(packageJSON, runSettings.package_config_options);
|
|
@@ -39,12 +41,16 @@ const setupPackageFolder = (runSettings, directoryPath) => {
|
|
|
39
41
|
let sourceNpmrc = path.join(cypressFolderPath, ".npmrc");
|
|
40
42
|
let destNpmrc = path.join(directoryPath, ".npmrc");
|
|
41
43
|
if (fs.existsSync(sourceNpmrc)) {
|
|
44
|
+
logger.debug(`Copying .npmrc file from ${sourceNpmrc} to ${destNpmrc}`);
|
|
42
45
|
fs.copyFileSync(sourceNpmrc, destNpmrc);
|
|
43
46
|
}
|
|
47
|
+
logger.debug(`${packagePath} file created with ${packageJSONString}`);
|
|
44
48
|
return resolve("Package file created");
|
|
45
49
|
}
|
|
50
|
+
logger.debug("Nothing in package file");
|
|
46
51
|
return reject("Nothing in package file");
|
|
47
52
|
} catch(error) {
|
|
53
|
+
logger.debug(`Creating ${directoryPath} failed with error ${error}`);
|
|
48
54
|
return reject(error);
|
|
49
55
|
}
|
|
50
56
|
})
|
|
@@ -59,12 +65,12 @@ const packageInstall = (packageDir) => {
|
|
|
59
65
|
resolve('Packages were installed successfully.');
|
|
60
66
|
} else {
|
|
61
67
|
logger.error(`Some error occurred while installing packages. Error code ${code}`);
|
|
62
|
-
reject(
|
|
68
|
+
reject(`Packages were not installed successfully. Error code ${code}`);
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
const nodeProcessErrorCallback = (error) => {
|
|
66
|
-
logger.error(`Some error occurred while installing packages:
|
|
67
|
-
reject(`Packages were not installed successfully. Error Description ${util.
|
|
72
|
+
logger.error(`Some error occurred while installing packages: %j`, error);
|
|
73
|
+
reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`);
|
|
68
74
|
};
|
|
69
75
|
nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install', '--loglevel', 'verbose', '>', '../npm_install_debug.log', '2>&1'], {cwd: packageDir, shell: true});
|
|
70
76
|
nodeProcess.on('close', nodeProcessCloseCallback);
|
|
@@ -82,6 +88,7 @@ const packageArchiver = (packageDir, packageFile) => {
|
|
|
82
88
|
if (err.code === 'ENOENT') {
|
|
83
89
|
logger.info(err);
|
|
84
90
|
} else {
|
|
91
|
+
logger.debug(`Archiving of node_modules failed with error ${err}`);
|
|
85
92
|
reject(err);
|
|
86
93
|
}
|
|
87
94
|
});
|
|
@@ -95,6 +102,7 @@ const packageArchiver = (packageDir, packageFile) => {
|
|
|
95
102
|
});
|
|
96
103
|
|
|
97
104
|
archive.on('error', function (err) {
|
|
105
|
+
logger.debug(`Archiving of node_modules failed with error ${err}`);
|
|
98
106
|
reject(err);
|
|
99
107
|
});
|
|
100
108
|
|
|
@@ -110,24 +118,32 @@ const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBl
|
|
|
110
118
|
packageArchieveCreated: false
|
|
111
119
|
};
|
|
112
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.")
|
|
113
122
|
return resolve(obj);
|
|
114
123
|
}
|
|
115
124
|
logger.info(Constants.userMessages.NPM_INSTALL_AND_UPLOAD);
|
|
116
125
|
instrumentBlocks.markBlockStart("packageInstaller.folderSetup");
|
|
126
|
+
logger.debug("Started setting up package folder");
|
|
117
127
|
return setupPackageFolder(bsConfig.run_settings, packageDir).then((_result) => {
|
|
128
|
+
logger.debug("Completed setting up package folder");
|
|
118
129
|
process.env.CYPRESS_INSTALL_BINARY = 0
|
|
119
130
|
instrumentBlocks.markBlockEnd("packageInstaller.folderSetup");
|
|
120
131
|
instrumentBlocks.markBlockStart("packageInstaller.packageInstall");
|
|
132
|
+
logger.debug("Started installing dependencies specified in browserstack.json");
|
|
121
133
|
return packageInstall(packageDir);
|
|
122
134
|
}).then((_result) => {
|
|
135
|
+
logger.debug("Completed installing dependencies");
|
|
123
136
|
instrumentBlocks.markBlockEnd("packageInstaller.packageInstall");
|
|
124
137
|
instrumentBlocks.markBlockStart("packageInstaller.packageArchive");
|
|
138
|
+
logger.debug("Started archiving node_modules")
|
|
125
139
|
return packageArchiver(packageDir, packageFile);
|
|
126
140
|
}).then((_result) => {
|
|
141
|
+
logger.debug("Archiving of node_modules completed");
|
|
127
142
|
instrumentBlocks.markBlockEnd("packageInstaller.packageArchive");
|
|
128
143
|
Object.assign(obj, { packageArchieveCreated: true });
|
|
129
144
|
return resolve(obj);
|
|
130
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.`);
|
|
131
147
|
obj.error = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
|
|
132
148
|
return resolve(obj);
|
|
133
149
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const logger = require("../logger").syncCliLogger;
|
|
2
|
+
const winstonlogger = require("../logger").winstonLogger;
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -16,7 +17,7 @@ const logger = require("../logger").syncCliLogger;
|
|
|
16
17
|
// {specName: 'spec8.alias.js', status: 'Skipped', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'}
|
|
17
18
|
// ]
|
|
18
19
|
//
|
|
19
|
-
let printSpecsRunSummary = (data, machines) => {
|
|
20
|
+
let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
|
|
20
21
|
return new Promise((resolve, _reject) => {
|
|
21
22
|
let summary = {
|
|
22
23
|
total: 0,
|
|
@@ -32,6 +33,21 @@ let printSpecsRunSummary = (data, machines) => {
|
|
|
32
33
|
logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}`);
|
|
33
34
|
logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
|
|
34
35
|
|
|
36
|
+
if (customErrorsToPrint && customErrorsToPrint.length > 0) {
|
|
37
|
+
for (const error of customErrorsToPrint) {
|
|
38
|
+
switch(error.level) {
|
|
39
|
+
case 'info':
|
|
40
|
+
winstonlogger.info(error.message);
|
|
41
|
+
break;
|
|
42
|
+
case 'error':
|
|
43
|
+
winstonlogger.error(error.message);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
winstonlogger.warn(error.message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
resolve(data.exitCode);
|
|
36
52
|
})
|
|
37
53
|
};
|
|
@@ -13,8 +13,10 @@ let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n =
|
|
|
13
13
|
let specSummary = {
|
|
14
14
|
"buildError": null,
|
|
15
15
|
"specs": [],
|
|
16
|
-
"duration": null
|
|
16
|
+
"duration": null,
|
|
17
|
+
"customErrorsToPrint": []
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
let noWrap = false;
|
|
19
21
|
let terminalWidth = (process.stdout.columns) * 0.9;
|
|
20
22
|
let lineSeparator = Constants.syncCLI.DEFAULT_LINE_SEP;
|
|
@@ -87,7 +89,10 @@ let setNoWrapParams = () => {
|
|
|
87
89
|
noWrap = (process.env.SYNC_NO_WRAP && (process.env.SYNC_NO_WRAP === 'true'));
|
|
88
90
|
// Do not show the separator based on terminal width if no-wrap provided.
|
|
89
91
|
if (noWrap) {
|
|
92
|
+
winstonLogger.debug("no-wrap is set to true, showing the default line separator irrespective of terminal width");
|
|
90
93
|
lineSeparator = Constants.syncCLI.DEFAULT_LINE_SEP;
|
|
94
|
+
} else {
|
|
95
|
+
winstonLogger.debug("no-wrap set to false, showing line separator based on terminal width.");
|
|
91
96
|
}
|
|
92
97
|
};
|
|
93
98
|
|
|
@@ -107,6 +112,7 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
|
|
|
107
112
|
},
|
|
108
113
|
function(err, result) { // when loop ends
|
|
109
114
|
if (err) {
|
|
115
|
+
winstonLogger.debug(`Error while fetching spec status :`, err);
|
|
110
116
|
if(err.status == 204) {
|
|
111
117
|
reject(specSummary.exitCode);
|
|
112
118
|
} else {
|
|
@@ -166,18 +172,22 @@ let getStackTraceUrl = () => {
|
|
|
166
172
|
let showSpecsStatus = (data) => {
|
|
167
173
|
let specData = JSON.parse(data);
|
|
168
174
|
specData.forEach(specDetails => {
|
|
169
|
-
if (specDetails
|
|
170
|
-
|
|
171
|
-
} else if (specDetails["stacktrace_url"]) {
|
|
172
|
-
specSummary.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
|
|
173
|
-
specSummary.buildError = specDetails["stacktrace_url"]
|
|
174
|
-
winstonLogger.error(chalk.red(specDetails["message"]));
|
|
175
|
+
if (specDetails.type === Constants.CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY) {
|
|
176
|
+
addCustomErrorToPrint(specDetails);
|
|
175
177
|
} else {
|
|
176
|
-
if(
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
if (specDetails == "created") {
|
|
179
|
+
return;
|
|
180
|
+
} else if (specDetails["stacktrace_url"]) {
|
|
181
|
+
specSummary.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
|
|
182
|
+
specSummary.buildError = specDetails["stacktrace_url"]
|
|
183
|
+
winstonLogger.error(chalk.red(specDetails["message"]));
|
|
184
|
+
} else {
|
|
185
|
+
if(!buildStarted) {
|
|
186
|
+
buildStarted = true
|
|
187
|
+
printInitialLog();
|
|
188
|
+
}
|
|
189
|
+
printSpecData(JSON.parse(specDetails));
|
|
179
190
|
}
|
|
180
|
-
printSpecData(JSON.parse(specDetails));
|
|
181
191
|
}
|
|
182
192
|
});
|
|
183
193
|
}
|
|
@@ -200,6 +210,17 @@ let writeToTable = (combination, specName, status) => {
|
|
|
200
210
|
stream.write([combination , ":", `${specName} ${status}`]);
|
|
201
211
|
}
|
|
202
212
|
|
|
213
|
+
let addCustomErrorToPrint = (error_object) => {
|
|
214
|
+
if (error_object["should_be_unique"]) {
|
|
215
|
+
for (const error of specSummary.customErrorsToPrint) {
|
|
216
|
+
if (error.id === error_object.id) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
specSummary.customErrorsToPrint.push(error_object);
|
|
222
|
+
}
|
|
223
|
+
|
|
203
224
|
let addSpecToSummary = (specName, status, combination, session_id) => {
|
|
204
225
|
// Format for part 3: {specName: 'spec1.failed.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
|
|
205
226
|
specSummary["specs"].push({
|
|
@@ -4,11 +4,15 @@ const syncSpecsLogs = require('./sync/syncSpecsLogs'),
|
|
|
4
4
|
specsSummary = require('./sync/specsSummary');
|
|
5
5
|
|
|
6
6
|
exports.pollBuildStatus = (bsConfig, buildDetails) => {
|
|
7
|
+
let customErrorsToPrint;
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails).then((data) => {
|
|
10
|
+
if(data.customErrorsToPrint && data.customErrorsToPrint.length > 0) {
|
|
11
|
+
customErrorsToPrint = data.customErrorsToPrint;
|
|
12
|
+
}
|
|
9
13
|
return specDetails.failedSpecsDetails(data);
|
|
10
14
|
}).then((data) => {
|
|
11
|
-
return specsSummary.printSpecsRunSummary(data, buildDetails.machines);
|
|
15
|
+
return specsSummary.printSpecsRunSummary(data, buildDetails.machines, customErrorsToPrint);
|
|
12
16
|
}).then((successExitCode) => {
|
|
13
17
|
resolve(successExitCode); // exit code 0
|
|
14
18
|
}).catch((nonZeroExitCode) => {
|
|
@@ -8,7 +8,7 @@ const cp = require("child_process"),
|
|
|
8
8
|
const config = require('./config'),
|
|
9
9
|
fileLogger = require('./logger').fileLogger,
|
|
10
10
|
utils = require('./utils');
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
const { AUTH_REGEX, REDACTED_AUTH, REDACTED, CLI_ARGS_REGEX, RAW_ARGS_REGEX } = require("./constants");
|
|
13
13
|
|
|
14
14
|
function get_version(package_name) {
|
|
@@ -172,6 +172,27 @@ function isUsageReportingEnabled() {
|
|
|
172
172
|
return process.env.DISABLE_USAGE_REPORTING;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
function redactBsConfig(bsConfig) {
|
|
176
|
+
if(typeof bsConfig === 'object' && !utils.isUndefined(bsConfig.run_settings)) {
|
|
177
|
+
if(!utils.isUndefined(bsConfig.run_settings["projectId"])) { bsConfig.run_settings["projectId"] = REDACTED }
|
|
178
|
+
if(!utils.isUndefined(bsConfig.run_settings["record-key"])) { bsConfig.run_settings["record-key"] = REDACTED }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function redactArgs(args) {
|
|
183
|
+
if(typeof args === 'object' && !utils.isUndefined(args.cli_args)) {
|
|
184
|
+
if(!utils.isUndefined(args.cli_args["projectId"])) { args.cli_args["projectId"] = REDACTED }
|
|
185
|
+
if(!utils.isUndefined(args.cli_args["project-id"])) { args.cli_args["project-id"] = REDACTED }
|
|
186
|
+
if(!utils.isUndefined(args.cli_args["record-key"])) { args.cli_args["record-key"] = REDACTED }
|
|
187
|
+
if(!utils.isUndefined(args.cli_args["recordKey"])) { args.cli_args["recordKey"] = REDACTED }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function redactRecordCaps(bsConfig, args) {
|
|
192
|
+
redactBsConfig(bsConfig);
|
|
193
|
+
redactArgs(args);
|
|
194
|
+
}
|
|
195
|
+
|
|
175
196
|
function redactKeys(str, regex, redact) {
|
|
176
197
|
return str.replace(regex, redact);
|
|
177
198
|
}
|
|
@@ -183,8 +204,10 @@ function send(args) {
|
|
|
183
204
|
let runSettings = "";
|
|
184
205
|
let sanitizedbsConfig = "";
|
|
185
206
|
let cli_details = cli_version_and_path(bsConfig);
|
|
186
|
-
let data = utils.isUndefined(args.data) ? {} : args.data;
|
|
187
207
|
|
|
208
|
+
redactRecordCaps(bsConfig, args);
|
|
209
|
+
|
|
210
|
+
let data = utils.isUndefined(args.data) ? {} : args.data;
|
|
188
211
|
if (bsConfig && bsConfig.run_settings) {
|
|
189
212
|
runSettings = bsConfig.run_settings;
|
|
190
213
|
data.cypress_version = bsConfig.run_settings.cypress_version;
|
package/bin/helpers/utils.js
CHANGED
|
@@ -16,7 +16,8 @@ const usageReporting = require("./usageReporting"),
|
|
|
16
16
|
syncCliLogger = require("../helpers/logger").syncCliLogger,
|
|
17
17
|
fileHelpers = require("./fileHelpers"),
|
|
18
18
|
config = require("../helpers/config"),
|
|
19
|
-
pkg = require('../../package.json')
|
|
19
|
+
pkg = require('../../package.json'),
|
|
20
|
+
transports = require('./logger').transports;
|
|
20
21
|
|
|
21
22
|
const request = require('request');
|
|
22
23
|
|
|
@@ -154,6 +155,7 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
|
|
|
154
155
|
} else {
|
|
155
156
|
process.env.DISABLE_USAGE_REPORTING = disableUsageReporting;
|
|
156
157
|
}
|
|
158
|
+
logger.debug(`Setting disable_usage_reporting flag as ${process.env.DISABLE_USAGE_REPORTING}`);
|
|
157
159
|
};
|
|
158
160
|
|
|
159
161
|
exports.getParallels = (bsConfig, args) => {
|
|
@@ -226,6 +228,7 @@ exports.setDefaults = (bsConfig, args) => {
|
|
|
226
228
|
exports.setUsername = (bsConfig, args) => {
|
|
227
229
|
if (!this.isUndefined(args.username)) {
|
|
228
230
|
bsConfig["auth"]["username"] = args.username;
|
|
231
|
+
logger.debug(`Reading username from command line = ${args.username}`);
|
|
229
232
|
} else if (!this.isUndefined(process.env.BROWSERSTACK_USERNAME)) {
|
|
230
233
|
bsConfig["auth"]["username"] = process.env.BROWSERSTACK_USERNAME;
|
|
231
234
|
logger.info(
|
|
@@ -237,6 +240,7 @@ exports.setUsername = (bsConfig, args) => {
|
|
|
237
240
|
exports.setAccessKey = (bsConfig, args) => {
|
|
238
241
|
if (!this.isUndefined(args.key)) {
|
|
239
242
|
bsConfig["auth"]["access_key"] = args.key;
|
|
243
|
+
logger.debug("Reading access_key from command line");
|
|
240
244
|
} else if (!this.isUndefined(process.env.BROWSERSTACK_ACCESS_KEY)) {
|
|
241
245
|
bsConfig["auth"]["access_key"] = process.env.BROWSERSTACK_ACCESS_KEY;
|
|
242
246
|
logger.info(
|
|
@@ -247,6 +251,7 @@ exports.setAccessKey = (bsConfig, args) => {
|
|
|
247
251
|
|
|
248
252
|
exports.setBuildName = (bsConfig, args) => {
|
|
249
253
|
if (!this.isUndefined(args["build-name"])) {
|
|
254
|
+
logger.debug(`Reading build name from command line = ${args["build-name"]}`);
|
|
250
255
|
bsConfig["run_settings"]["build_name"] = args["build-name"];
|
|
251
256
|
}
|
|
252
257
|
};
|
|
@@ -286,6 +291,8 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
|
|
|
286
291
|
bsConfig.run_settings.cypressConfigFilePath = path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json');
|
|
287
292
|
bsConfig.run_settings.cypressProjectDir = bsConfig.run_settings.cypress_proj_dir;
|
|
288
293
|
}
|
|
294
|
+
logger.debug(`Setting cypress config file path = ${bsConfig.run_settings.cypressConfigFilePath}`);
|
|
295
|
+
logger.debug(`Setting cypress project dir = ${bsConfig.run_settings.cypressProjDir}`);
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
exports.verifyGeolocationOption = () => {
|
|
@@ -308,6 +315,7 @@ exports.setGeolocation = (bsConfig, args) => {
|
|
|
308
315
|
} else {
|
|
309
316
|
bsConfig.run_settings.geolocation = bsConfig.run_settings.geolocation.toUpperCase();
|
|
310
317
|
}
|
|
318
|
+
logger.debug(`Setting geolocation = ${bsConfig.run_settings.geolocation}`);
|
|
311
319
|
}
|
|
312
320
|
|
|
313
321
|
exports.isSpecTimeoutArgPassed = () => {
|
|
@@ -325,6 +333,42 @@ exports.setSpecTimeout = (bsConfig, args) => {
|
|
|
325
333
|
specTimeout = bsConfig.run_settings.spec_timeout;
|
|
326
334
|
}
|
|
327
335
|
bsConfig.run_settings.spec_timeout = specTimeout;
|
|
336
|
+
logger.debug(`Setting spec timeout = ${specTimeout}`);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
exports.setRecordFlag = (bsConfig, args) => {
|
|
340
|
+
if(!this.isUndefined(args["record"])) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
return bsConfig.run_settings["record"];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
exports.setRecordKeyFlag = (bsConfig, args) => {
|
|
347
|
+
if(!this.isUndefined(args["record-key"])) {
|
|
348
|
+
return args["record-key"];
|
|
349
|
+
} else if (!this.isUndefined(process.env.CYPRESS_RECORD_KEY)) {
|
|
350
|
+
return process.env.CYPRESS_RECORD_KEY;
|
|
351
|
+
}
|
|
352
|
+
return bsConfig.run_settings["record-key"];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
exports.setProjectId = (bsConfig, args) => {
|
|
356
|
+
if(!this.isUndefined(args["projectId"])) {
|
|
357
|
+
return args["projectId"];
|
|
358
|
+
} else if(!this.isUndefined(process.env.CYPRESS_PROJECT_ID)) {
|
|
359
|
+
return process.env.CYPRESS_PROJECT_ID;
|
|
360
|
+
} else if(!this.isUndefined(bsConfig.run_settings["projectId"])) {
|
|
361
|
+
return bsConfig.run_settings["projectId"];
|
|
362
|
+
} else {
|
|
363
|
+
let cypressJson = this.getCypressJSON(bsConfig);
|
|
364
|
+
if (!this.isUndefined(cypressJson) && !this.isUndefined(cypressJson["projectId"])) { return cypressJson["projectId"]; }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
exports.setRecordCaps = (bsConfig, args) => {
|
|
369
|
+
bsConfig.run_settings["record"] = this.setRecordFlag(bsConfig, args);
|
|
370
|
+
bsConfig.run_settings["record-key"] = this.setRecordKeyFlag(bsConfig, args);
|
|
371
|
+
bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args);
|
|
328
372
|
}
|
|
329
373
|
|
|
330
374
|
// specs can be passed from bstack configuration file
|
|
@@ -335,6 +379,7 @@ exports.setUserSpecs = (bsConfig, args) => {
|
|
|
335
379
|
|
|
336
380
|
if (!this.isUndefined(args.specs)) {
|
|
337
381
|
bsConfig.run_settings.specs = this.fixCommaSeparatedString(args.specs);
|
|
382
|
+
logger.debug(`Specs provided to run using CLI argument = ${bsConfig.run_settings.specs}`);
|
|
338
383
|
} else if (!this.isUndefined(bsConfigSpecs) && Array.isArray(bsConfigSpecs)) {
|
|
339
384
|
bsConfig.run_settings.specs = bsConfigSpecs.join(',');
|
|
340
385
|
} else if (!this.isUndefined(bsConfigSpecs) && typeof(bsConfigSpecs) == "string") {
|
|
@@ -365,6 +410,8 @@ exports.setTestEnvs = (bsConfig, args) => {
|
|
|
365
410
|
} else {
|
|
366
411
|
bsConfig.run_settings.env = Object.keys(envKeys).map(key => (`${key}=${envKeys[key]}`)).join(',');
|
|
367
412
|
}
|
|
413
|
+
|
|
414
|
+
logger.debug(`Setting env vars = ${bsConfig.run_settings.env}`);
|
|
368
415
|
}
|
|
369
416
|
|
|
370
417
|
exports.setSystemEnvs = (bsConfig) => {
|
|
@@ -392,6 +439,8 @@ exports.setSystemEnvs = (bsConfig) => {
|
|
|
392
439
|
} else {
|
|
393
440
|
bsConfig.run_settings.system_env_vars = Object.keys(envKeys).map(key => (`${key}=${envKeys[key]}`));
|
|
394
441
|
}
|
|
442
|
+
|
|
443
|
+
logger.debug(`Setting system env vars = ${bsConfig.run_settings.system_env_vars}`);
|
|
395
444
|
}
|
|
396
445
|
|
|
397
446
|
exports.getKeysMatchingPattern = (obj, pattern) => {
|
|
@@ -466,6 +515,7 @@ exports.configCreated = (args) => {
|
|
|
466
515
|
|
|
467
516
|
exports.exportResults = (buildId, buildUrl) => {
|
|
468
517
|
let data = "BUILD_ID=" + buildId + "\nBUILD_URL=" + buildUrl;
|
|
518
|
+
logger.debug("Writing build results to log/build_results.txt");
|
|
469
519
|
fs.writeFileSync("log/build_results.txt", data, function (err) {
|
|
470
520
|
if (err) {
|
|
471
521
|
logger.warn(
|
|
@@ -586,6 +636,7 @@ exports.setLocal = (bsConfig, args) => {
|
|
|
586
636
|
local = true;
|
|
587
637
|
}
|
|
588
638
|
bsConfig['connection_settings']['local'] = local;
|
|
639
|
+
logger.debug(`Reading local setting from command line as ${local}`);
|
|
589
640
|
} else if (!this.isUndefined(process.env.BROWSERSTACK_LOCAL)) {
|
|
590
641
|
let local = false;
|
|
591
642
|
if (String(process.env.BROWSERSTACK_LOCAL).toLowerCase() === 'true') {
|
|
@@ -660,6 +711,7 @@ exports.setLocalMode = (bsConfig, args) => {
|
|
|
660
711
|
if (localModeInferred && localModeUndefined) {
|
|
661
712
|
bsConfig.connection_settings.local_mode_inferred = local_mode;
|
|
662
713
|
}
|
|
714
|
+
logger.debug(`local_mode set to ${bsConfig.connection_settings.local_mode_inferred}`);
|
|
663
715
|
}
|
|
664
716
|
};
|
|
665
717
|
|
|
@@ -679,6 +731,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
679
731
|
process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
|
|
680
732
|
}
|
|
681
733
|
if (!localIdentifierRunning){
|
|
734
|
+
logger.debug(`Local binary with identifier ${bsConfig["connection_settings"]["local_identifier"]} not running. Starting a new connection.`);
|
|
682
735
|
bsConfig.connection_settings.usedAutoLocal = true;
|
|
683
736
|
var bs_local = this.getLocalBinary();
|
|
684
737
|
var bs_local_args = this.setLocalArgs(bsConfig, args);
|
|
@@ -689,6 +742,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
689
742
|
process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
|
|
690
743
|
resolve(bs_local);
|
|
691
744
|
} else {
|
|
745
|
+
logger.debug(`Error occured while starting a new Local connection with error :`,localStartError);
|
|
692
746
|
let message = `name: ${localStartError.name}, message: ${localStartError.message}, extra: ${localStartError.extra}`,
|
|
693
747
|
errorCode = "local_start_error";
|
|
694
748
|
that.sendUsageReport(
|
|
@@ -720,6 +774,7 @@ exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
|
|
|
720
774
|
if (that.isUndefined(localStopError)) {
|
|
721
775
|
resolve();
|
|
722
776
|
} else {
|
|
777
|
+
logger.debug(`Stopping local binary failed with error`, localStopError);
|
|
723
778
|
let message = `name: ${localStopError.name}, message: ${localStopError.message}, extra: ${localStopError.extra}`,
|
|
724
779
|
errorCode = 'local_stop_error';
|
|
725
780
|
that.sendUsageReport(
|
|
@@ -768,6 +823,7 @@ exports.generateLocalIdentifier = (mode) => {
|
|
|
768
823
|
};
|
|
769
824
|
|
|
770
825
|
exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
|
|
826
|
+
logger.debug("Checking if local binary running");
|
|
771
827
|
let options = {
|
|
772
828
|
url: `${config.cypress_v1}/local_binary_running_check`,
|
|
773
829
|
auth: {
|
|
@@ -794,6 +850,7 @@ exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
|
|
|
794
850
|
exports.setLocalConfigFile = (bsConfig, args) => {
|
|
795
851
|
if(!this.isUndefined(args.localConfigFile)){
|
|
796
852
|
bsConfig['connection_settings']['local_config_file'] = args.localConfigFile;
|
|
853
|
+
logger.debug(`local_config_file set to ${bsConfig['connection_settings']['local_config_file']}`);
|
|
797
854
|
}
|
|
798
855
|
};
|
|
799
856
|
|
|
@@ -801,6 +858,7 @@ exports.setHeaded = (bsConfig, args) => {
|
|
|
801
858
|
if (!this.isUndefined(args.headed) && args.headed === true) {
|
|
802
859
|
bsConfig.run_settings.headless = false;
|
|
803
860
|
}
|
|
861
|
+
logger.debug(`headless mode set to ${bsConfig.run_settings.headless}`);
|
|
804
862
|
};
|
|
805
863
|
|
|
806
864
|
exports.setNoWrap = (_bsConfig, args) => {
|
|
@@ -809,6 +867,7 @@ exports.setNoWrap = (_bsConfig, args) => {
|
|
|
809
867
|
} else {
|
|
810
868
|
process.env.SYNC_NO_WRAP = false;
|
|
811
869
|
}
|
|
870
|
+
logger.debug(`no-wrap set to ${process.env.SYNC_NO_WRAP}`);
|
|
812
871
|
}
|
|
813
872
|
|
|
814
873
|
exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
|
|
@@ -833,6 +892,7 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressJson) => {
|
|
|
833
892
|
let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
|
|
834
893
|
let ignoreFiles = args.exclude || bsConfig.run_settings.exclude;
|
|
835
894
|
let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
|
|
895
|
+
logger.debug(`${files ? files.length : 0} spec files found at ${testFolderPath}`);
|
|
836
896
|
return files;
|
|
837
897
|
};
|
|
838
898
|
|
|
@@ -949,6 +1009,7 @@ exports.setBrowsers = async (bsConfig, args) => {
|
|
|
949
1009
|
browserHash['versions'].push(this.isUndefined(browserDetails[1]) ? "latest" : browserDetails[1].trim())
|
|
950
1010
|
bsConfig["browsers"].push(browserHash)
|
|
951
1011
|
});
|
|
1012
|
+
logger.debug(`Browsers provided ${bsConfig["browsers"]}`);
|
|
952
1013
|
} catch(err){
|
|
953
1014
|
reject(Constants.validationMessages.INVALID_BROWSER_ARGS)
|
|
954
1015
|
}
|
|
@@ -960,6 +1021,7 @@ exports.setBrowsers = async (bsConfig, args) => {
|
|
|
960
1021
|
exports.setConfig = (bsConfig, args) => {
|
|
961
1022
|
if (!this.isUndefined(args.config)) {
|
|
962
1023
|
bsConfig["run_settings"]["config"] = args.config
|
|
1024
|
+
logger.debug(`Config set to ${bsConfig["run_settings"]["config"]}`);
|
|
963
1025
|
}
|
|
964
1026
|
}
|
|
965
1027
|
|
|
@@ -967,9 +1029,11 @@ exports.setConfig = (bsConfig, args) => {
|
|
|
967
1029
|
exports.setOtherConfigs = (bsConfig, args) => {
|
|
968
1030
|
if (!this.isUndefined(args.reporter)) {
|
|
969
1031
|
bsConfig["run_settings"]["reporter"] = args.reporter;
|
|
1032
|
+
logger.debug(`reporter set to ${args.reporter}`);
|
|
970
1033
|
}
|
|
971
1034
|
if (!this.isUndefined(args.reporterOptions)) {
|
|
972
1035
|
bsConfig["run_settings"]["reporter_options"] = args.reporterOptions;
|
|
1036
|
+
logger.debug(`reporter-options set to ${args.reporterOptions}`);
|
|
973
1037
|
}
|
|
974
1038
|
}
|
|
975
1039
|
|
|
@@ -1001,6 +1065,7 @@ exports.setCLIMode = (bsConfig, args) => {
|
|
|
1001
1065
|
if(!this.isUndefined(args.async) && args.async){
|
|
1002
1066
|
args.sync = false;
|
|
1003
1067
|
}
|
|
1068
|
+
logger.debug(`sync mode set to ${args.sync}`);
|
|
1004
1069
|
}
|
|
1005
1070
|
|
|
1006
1071
|
exports.formatRequest = (err, resp, body) => {
|
|
@@ -1011,6 +1076,19 @@ exports.formatRequest = (err, resp, body) => {
|
|
|
1011
1076
|
}
|
|
1012
1077
|
}
|
|
1013
1078
|
|
|
1079
|
+
exports.setDebugMode = (args) => {
|
|
1080
|
+
if(args.cliDebug || String(process.env.DEBUG).toLowerCase() === 'true'){
|
|
1081
|
+
args.cliDebug ?
|
|
1082
|
+
logger.info("CLI is running with the --cli-debug argument. Running CLI in the debug mode...") :
|
|
1083
|
+
logger.info("DEBUG environment variable set to 'true'. Running CLI in the debug mode...") ;
|
|
1084
|
+
transports.loggerConsole.level = 'debug';
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
transports.loggerConsole.level = 'info';
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
|
|
1014
1092
|
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
1015
1093
|
let that = this;
|
|
1016
1094
|
return new Promise(function (resolve, reject) {
|
|
@@ -1120,5 +1198,7 @@ exports.getVideoConfig = (cypressJson) => {
|
|
|
1120
1198
|
if (!this.isUndefined(cypressJson.video)) conf.video = cypressJson.video;
|
|
1121
1199
|
if (!this.isUndefined(cypressJson.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressJson.videoUploadOnPasses;
|
|
1122
1200
|
|
|
1201
|
+
logger.debug(`Setting video = ${conf.video}`);
|
|
1202
|
+
logger.debug(`Setting videoUploadOnPasses = ${conf.videoUploadOnPasses}`);
|
|
1123
1203
|
return conf;
|
|
1124
1204
|
}
|
package/bin/helpers/zipUpload.js
CHANGED
|
@@ -69,7 +69,11 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if (!opts.propogateError){
|
|
72
|
-
|
|
72
|
+
purgeUploadBar(obj);
|
|
73
|
+
if (resp.statusCode == 413) {
|
|
74
|
+
return resolve({warn: Constants.userMessages.NODE_MODULES_LIMIT_EXCEEDED.replace("%SIZE%", (size / 1000000).toFixed(2))});
|
|
75
|
+
}
|
|
76
|
+
return resolve({})
|
|
73
77
|
}
|
|
74
78
|
if(responseData && responseData["error"]){
|
|
75
79
|
responseData["time"] = Date.now() - obj.startTime;
|
|
@@ -137,6 +141,9 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
|
|
|
137
141
|
let npmPackageUpload = uploadSuits(bsConfig, config.packageFileName, npmOptions, npmPackageZipUploadObj);
|
|
138
142
|
Promise.all([zipUpload, npmPackageUpload]).then(function (uploads) {
|
|
139
143
|
uploads.forEach(upload => {
|
|
144
|
+
if(upload.warn) {
|
|
145
|
+
logger.warn(upload.warn);
|
|
146
|
+
}
|
|
140
147
|
if(upload.zip_url && upload.time) {
|
|
141
148
|
upload.tests_upload_time = upload.time;
|
|
142
149
|
} else if (upload.npm_package_url && upload.time) {
|
package/bin/runner.js
CHANGED
|
@@ -43,11 +43,20 @@ const configFileOptions = {
|
|
|
43
43
|
},
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const debugModeOptions = {
|
|
47
|
+
'cli-debug': {
|
|
48
|
+
default: false,
|
|
49
|
+
describe: Constants.cliMessages.COMMON.DEBUG,
|
|
50
|
+
type: "boolean"
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
const commonBuildOptions = {
|
|
47
55
|
...configFileOptions,
|
|
48
56
|
...disableUsageReportingOptions,
|
|
49
57
|
...usernameOptions,
|
|
50
58
|
...accessKeyOptions,
|
|
59
|
+
...debugModeOptions,
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
function checkCommands(yargs, argv, numRequired) {
|
|
@@ -243,6 +252,20 @@ var argv = yargs
|
|
|
243
252
|
describe: Constants.cliMessages.RUN.REPORTER_OPTIONS,
|
|
244
253
|
type: "string"
|
|
245
254
|
},
|
|
255
|
+
'record': {
|
|
256
|
+
describe: Constants.cliMessages.RUN.RECORD,
|
|
257
|
+
type: "boolean"
|
|
258
|
+
},
|
|
259
|
+
'record-key': {
|
|
260
|
+
default: undefined,
|
|
261
|
+
describe: Constants.cliMessages.RUN.RECORD_KEY,
|
|
262
|
+
type: "string"
|
|
263
|
+
},
|
|
264
|
+
'projectId': {
|
|
265
|
+
default: undefined,
|
|
266
|
+
describe: Constants.cliMessages.RUN.PROJECT_ID,
|
|
267
|
+
type: "string"
|
|
268
|
+
}
|
|
246
269
|
})
|
|
247
270
|
.help('help')
|
|
248
271
|
.wrap(null)
|