browserstack-cypress-cli 1.28.2 → 1.29.1
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/.nyc_output/2db2627f-2e11-464d-ae01-f6230871649b.json +1 -0
- package/.nyc_output/4c186da0-310d-4c8d-8094-a12765ea5729.json +1 -0
- package/.nyc_output/processinfo/2db2627f-2e11-464d-ae01-f6230871649b.json +1 -0
- package/.nyc_output/processinfo/4c186da0-310d-4c8d-8094-a12765ea5729.json +1 -0
- package/.nyc_output/processinfo/4ece437f-21da-4310-a4f4-6b7e2c9c758c.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CODEOWNERS +1 -1
- package/bin/accessibility-automation/cypress/index.js +352 -109
- package/bin/accessibility-automation/helper.js +27 -14
- package/bin/accessibility-automation/plugin/index.js +11 -1
- package/bin/commands/runs.js +9 -1
- package/bin/helpers/capabilityHelper.js +20 -3
- package/bin/helpers/helper.js +74 -0
- package/bin/helpers/utils.js +1 -0
- package/bin/testObservability/helper/helper.js +23 -12
- package/package.json +1 -1
- package/.nyc_output/5bfb514c-7f4c-4d7d-a340-aea45b6df22a.json +0 -1
- package/.nyc_output/6560b7ed-7bb3-4356-8e02-8e3b87e338df.json +0 -1
- package/.nyc_output/7bd0aff0-4e4e-48e2-a4b4-5759ca2809a1.json +0 -1
- package/.nyc_output/9026361d-cf67-46f1-be8c-1cca46df290c.json +0 -1
- package/.nyc_output/96b48768-47a7-4ce2-a594-f8cce51372d0.json +0 -1
- package/.nyc_output/981ac816-df8a-44d0-a0c4-492f9866d7ae.json +0 -1
- package/.nyc_output/ad567238-328d-4698-917f-a91539e16070.json +0 -1
- package/.nyc_output/ad864605-6250-44da-a38d-e3fc5d9d3d7d.json +0 -1
- package/.nyc_output/c6e6f4da-56a6-437e-b5f0-82d29d9536e6.json +0 -1
- package/.nyc_output/cb28d15a-b052-44a2-89d1-184cdf7a4ffc.json +0 -1
- package/.nyc_output/dc944854-f4c9-49a2-a907-b8eacbe61ea2.json +0 -1
- package/.nyc_output/e93ac7d5-aca6-473c-b715-9b11594cd0ff.json +0 -1
- package/.nyc_output/e97f3f73-9ecb-4391-aa1a-8afe1fd3895b.json +0 -1
- package/.nyc_output/processinfo/4de31829-b694-4567-a64d-b9f2a39aad8f.json +0 -1
- package/.nyc_output/processinfo/5bfb514c-7f4c-4d7d-a340-aea45b6df22a.json +0 -1
- package/.nyc_output/processinfo/6560b7ed-7bb3-4356-8e02-8e3b87e338df.json +0 -1
- package/.nyc_output/processinfo/7bd0aff0-4e4e-48e2-a4b4-5759ca2809a1.json +0 -1
- package/.nyc_output/processinfo/9026361d-cf67-46f1-be8c-1cca46df290c.json +0 -1
- package/.nyc_output/processinfo/96b48768-47a7-4ce2-a594-f8cce51372d0.json +0 -1
- package/.nyc_output/processinfo/981ac816-df8a-44d0-a0c4-492f9866d7ae.json +0 -1
- package/.nyc_output/processinfo/ad567238-328d-4698-917f-a91539e16070.json +0 -1
- package/.nyc_output/processinfo/ad864605-6250-44da-a38d-e3fc5d9d3d7d.json +0 -1
- package/.nyc_output/processinfo/c6e6f4da-56a6-437e-b5f0-82d29d9536e6.json +0 -1
- package/.nyc_output/processinfo/cb28d15a-b052-44a2-89d1-184cdf7a4ffc.json +0 -1
- package/.nyc_output/processinfo/dc944854-f4c9-49a2-a907-b8eacbe61ea2.json +0 -1
- package/.nyc_output/processinfo/e93ac7d5-aca6-473c-b715-9b11594cd0ff.json +0 -1
- package/.nyc_output/processinfo/e97f3f73-9ecb-4391-aa1a-8afe1fd3895b.json +0 -1
- /package/.nyc_output/{4de31829-b694-4567-a64d-b9f2a39aad8f.json → 4ece437f-21da-4310-a4f4-6b7e2c9c758c.json} +0 -0
|
@@ -66,7 +66,10 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
66
66
|
'source': {
|
|
67
67
|
frameworkName: "Cypress",
|
|
68
68
|
frameworkVersion: helper.getPackageVersion('cypress', user_config),
|
|
69
|
-
sdkVersion: helper.getAgentVersion()
|
|
69
|
+
sdkVersion: helper.getAgentVersion(),
|
|
70
|
+
language: 'javascript',
|
|
71
|
+
testFramework: 'cypress',
|
|
72
|
+
testFrameworkVersion: helper.getPackageVersion('cypress', user_config)
|
|
70
73
|
},
|
|
71
74
|
'settings': settings,
|
|
72
75
|
'versionControl': await helper.getGitMetaData(),
|
|
@@ -92,7 +95,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
const response = await nodeRequest(
|
|
95
|
-
'POST', 'test_runs', data, config, API_URL
|
|
98
|
+
'POST', 'v2/test_runs', data, config, API_URL
|
|
96
99
|
);
|
|
97
100
|
if(!utils.isUndefined(response.data)) {
|
|
98
101
|
process.env.BS_A11Y_JWT = response.data.data.accessibilityToken;
|
|
@@ -104,7 +107,6 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
104
107
|
logger.debug(`BrowserStack Accessibility Automation Test Run ID: ${response.data.data.id}`);
|
|
105
108
|
|
|
106
109
|
this.setAccessibilityCypressCapabilities(user_config, response.data);
|
|
107
|
-
setAccessibilityEventListeners();
|
|
108
110
|
helper.setBrowserstackCypressCliDependency(user_config);
|
|
109
111
|
|
|
110
112
|
} catch (error) {
|
|
@@ -172,41 +174,52 @@ const nodeRequest = (type, url, data, config) => {
|
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
exports.supportFileCleanup = () => {
|
|
175
|
-
logger.debug("Cleaning up support file changes added for accessibility.
|
|
177
|
+
logger.debug("Cleaning up support file changes added for accessibility.")
|
|
176
178
|
Object.keys(supportFileContentMap).forEach(file => {
|
|
177
179
|
try {
|
|
178
|
-
|
|
180
|
+
if(typeof supportFileContentMap[file] === 'object') {
|
|
181
|
+
let fileOrDirpath = file;
|
|
182
|
+
if(supportFileContentMap[file].deleteSupportDir) {
|
|
183
|
+
fileOrDirpath = path.join(process.cwd(), 'cypress', 'support');
|
|
184
|
+
}
|
|
185
|
+
helper.deleteSupportFileOrDir(fileOrDirpath);
|
|
186
|
+
} else {
|
|
187
|
+
fs.writeFileSync(file, supportFileContentMap[file], {encoding: 'utf-8'});
|
|
188
|
+
}
|
|
179
189
|
} catch(e) {
|
|
180
190
|
logger.debug(`Error while replacing file content for ${file} with it's original content with error : ${e}`, true, e);
|
|
181
191
|
}
|
|
182
192
|
});
|
|
183
193
|
}
|
|
184
194
|
|
|
185
|
-
const getAccessibilityCypressCommandEventListener = () => {
|
|
186
|
-
return (
|
|
195
|
+
const getAccessibilityCypressCommandEventListener = (extName) => {
|
|
196
|
+
return extName == 'js' ? (
|
|
187
197
|
`require('browserstack-cypress-cli/bin/accessibility-automation/cypress');`
|
|
188
|
-
)
|
|
198
|
+
) : (
|
|
199
|
+
`import 'browserstack-cypress-cli/bin/accessibility-automation/cypress'`
|
|
200
|
+
)
|
|
189
201
|
}
|
|
190
202
|
|
|
191
|
-
|
|
203
|
+
exports.setAccessibilityEventListeners = (bsConfig) => {
|
|
192
204
|
try {
|
|
193
|
-
const cypressCommandEventListener = getAccessibilityCypressCommandEventListener();
|
|
194
|
-
|
|
195
205
|
// Searching form command.js recursively
|
|
196
|
-
|
|
206
|
+
const supportFilesData = helper.getSupportFiles(bsConfig, true);
|
|
207
|
+
if(!supportFilesData.supportFile) return;
|
|
208
|
+
glob(process.cwd() + supportFilesData.supportFile, {}, (err, files) => {
|
|
197
209
|
if(err) return logger.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
|
|
198
210
|
files.forEach(file => {
|
|
199
211
|
try {
|
|
200
|
-
if(!file.includes('commands.js')) {
|
|
212
|
+
if(!file.includes('commands.js') && !file.includes('commands.ts')) {
|
|
201
213
|
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
|
|
202
214
|
|
|
215
|
+
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file));
|
|
203
216
|
if(!defaultFileContent.includes(cypressCommandEventListener)) {
|
|
204
217
|
let newFileContent = defaultFileContent +
|
|
205
218
|
'\n' +
|
|
206
219
|
cypressCommandEventListener +
|
|
207
220
|
'\n'
|
|
208
221
|
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
|
|
209
|
-
supportFileContentMap[file] = defaultFileContent;
|
|
222
|
+
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent;
|
|
210
223
|
}
|
|
211
224
|
}
|
|
212
225
|
} catch(e) {
|
|
@@ -3,9 +3,19 @@ const path = require("node:path");
|
|
|
3
3
|
|
|
4
4
|
const browserstackAccessibility = (on, config) => {
|
|
5
5
|
let browser_validation = true;
|
|
6
|
+
if (process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG === 'true') {
|
|
7
|
+
config.env.BROWSERSTACK_LOGS = 'true';
|
|
8
|
+
process.env.BROWSERSTACK_LOGS = 'true';
|
|
9
|
+
}
|
|
10
|
+
on('task', {
|
|
11
|
+
browserstack_log(message) {
|
|
12
|
+
console.log(message)
|
|
13
|
+
|
|
14
|
+
return null
|
|
15
|
+
},
|
|
16
|
+
})
|
|
6
17
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
7
18
|
try {
|
|
8
|
-
|
|
9
19
|
if (process.env.ACCESSIBILITY_EXTENSION_PATH !== undefined) {
|
|
10
20
|
if (browser.name !== 'chrome') {
|
|
11
21
|
console.log(`Accessibility Automation will run only on Chrome browsers.`);
|
package/bin/commands/runs.js
CHANGED
|
@@ -25,6 +25,7 @@ const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
|
|
|
25
25
|
|
|
26
26
|
const {
|
|
27
27
|
launchTestSession,
|
|
28
|
+
setEventListeners,
|
|
28
29
|
setTestObservabilityFlags,
|
|
29
30
|
runCypressTestsLocally,
|
|
30
31
|
printBuildLink
|
|
@@ -33,6 +34,7 @@ const {
|
|
|
33
34
|
|
|
34
35
|
const {
|
|
35
36
|
createAccessibilityTestRun,
|
|
37
|
+
setAccessibilityEventListeners,
|
|
36
38
|
checkAccessibilityPlatform,
|
|
37
39
|
supportFileCleanup
|
|
38
40
|
} = require('../accessibility-automation/helper');
|
|
@@ -146,7 +148,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
146
148
|
|
|
147
149
|
// add cypress dependency if missing
|
|
148
150
|
utils.setCypressNpmDependency(bsConfig);
|
|
149
|
-
|
|
151
|
+
|
|
150
152
|
if (isAccessibilitySession && isBrowserstackInfra) {
|
|
151
153
|
await createAccessibilityTestRun(bsConfig);
|
|
152
154
|
}
|
|
@@ -205,6 +207,12 @@ module.exports = function run(args, rawArgs) {
|
|
|
205
207
|
markBlockStart('validateConfig');
|
|
206
208
|
logger.debug("Started configs validation");
|
|
207
209
|
return capabilityHelper.validate(bsConfig, args).then(function (cypressConfigFile) {
|
|
210
|
+
if(process.env.BROWSERSTACK_TEST_ACCESSIBILITY) {
|
|
211
|
+
setAccessibilityEventListeners(bsConfig);
|
|
212
|
+
}
|
|
213
|
+
if(process.env.BS_TESTOPS_BUILD_COMPLETED) {
|
|
214
|
+
// setEventListeners(bsConfig);
|
|
215
|
+
}
|
|
208
216
|
markBlockEnd('validateConfig');
|
|
209
217
|
logger.debug("Completed configs validation");
|
|
210
218
|
markBlockStart('preArchiveSteps');
|
|
@@ -122,6 +122,8 @@ const caps = (bsConfig, zip) => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true') {
|
|
125
|
+
// If any of the platform has accessibility true, make it true
|
|
126
|
+
bsConfig.run_settings["accessibility"] = true;
|
|
125
127
|
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig);
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -147,14 +149,29 @@ const caps = (bsConfig, zip) => {
|
|
|
147
149
|
})
|
|
148
150
|
}
|
|
149
151
|
const getAccessibilityPlatforms = (bsConfig) => {
|
|
150
|
-
const browserList =
|
|
152
|
+
const browserList = [];
|
|
153
|
+
if (bsConfig.browsers) {
|
|
154
|
+
bsConfig.browsers.forEach((element) => {
|
|
155
|
+
element.versions.forEach((version) => {
|
|
156
|
+
browserList.push({...element, version, platform: element.os + "-" + element.browser});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
151
161
|
const accessibilityPlatforms = Array(browserList.length).fill(false);
|
|
152
162
|
let rootLevelAccessibility = false;
|
|
153
163
|
if (!Utils.isUndefined(bsConfig.run_settings.accessibility)) {
|
|
154
|
-
rootLevelAccessibility = bsConfig.run_settings.accessibility.toString() === 'true'
|
|
164
|
+
rootLevelAccessibility = bsConfig.run_settings.accessibility.toString() === 'true';
|
|
155
165
|
}
|
|
156
166
|
browserList.forEach((browserDetails, idx) => {
|
|
157
|
-
accessibilityPlatforms[idx] = (browserDetails.accessibility === undefined) ? rootLevelAccessibility : browserDetails.accessibility
|
|
167
|
+
accessibilityPlatforms[idx] = (browserDetails.accessibility === undefined) ? rootLevelAccessibility : browserDetails.accessibility;
|
|
168
|
+
if (Utils.isUndefined(bsConfig.run_settings.headless) || !(String(bsConfig.run_settings.headless) === "false")) {
|
|
169
|
+
logger.warn(`Accessibility Automation will not run on legacy headless mode. Switch to new headless mode or avoid using headless mode for ${browserDetails.platform}.`);
|
|
170
|
+
} else if (browserDetails.browser && browserDetails.browser.toLowerCase() !== 'chrome') {
|
|
171
|
+
logger.warn(`Accessibility Automation will run only on Chrome browsers for ${browserDetails.platform}.`);
|
|
172
|
+
} else if (browserDetails.version && !browserDetails.version.includes('latest') && browserDetails.version <= 94) {
|
|
173
|
+
logger.warn(`Accessibility Automation will run only on Chrome browser version greater than 94 for ${browserDetails.platform}.`);
|
|
174
|
+
}
|
|
158
175
|
});
|
|
159
176
|
return accessibilityPlatforms;
|
|
160
177
|
}
|
package/bin/helpers/helper.js
CHANGED
|
@@ -16,6 +16,7 @@ const gitconfig = require('gitconfiglocal');
|
|
|
16
16
|
const { spawn, execSync } = require('child_process');
|
|
17
17
|
const glob = require('glob');
|
|
18
18
|
const pGitconfig = promisify(gitconfig);
|
|
19
|
+
const { readCypressConfigFile } = require('./readCypressConfigUtil');
|
|
19
20
|
const CrashReporter = require('../testObservability/crashReporter');
|
|
20
21
|
|
|
21
22
|
exports.debug = (text, shouldReport = false, throwable = null) => {
|
|
@@ -313,3 +314,76 @@ exports.setBrowserstackCypressCliDependency = (bsConfig) => {
|
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
}
|
|
317
|
+
|
|
318
|
+
exports.deleteSupportFileOrDir = (fileOrDirPath) => {
|
|
319
|
+
try {
|
|
320
|
+
// Sanitize the input to remove any characters that could be used for directory traversal
|
|
321
|
+
const sanitizedPath = fileOrDirPath.replace(/(\.\.\/|\.\/|\/\/)/g, '');
|
|
322
|
+
const resolvedPath = path.resolve(sanitizedPath);
|
|
323
|
+
if (fs.existsSync(resolvedPath)) {
|
|
324
|
+
if (fs.lstatSync(resolvedPath).isDirectory()) {
|
|
325
|
+
fs.readdirSync(resolvedPath).forEach((file) => {
|
|
326
|
+
const sanitizedFile = file.replace(/(\.\.\/|\.\/|\/\/)/g, '');
|
|
327
|
+
const currentPath = path.join(resolvedPath, sanitizedFile);
|
|
328
|
+
fs.unlinkSync(currentPath);
|
|
329
|
+
});
|
|
330
|
+
fs.rmdirSync(resolvedPath);
|
|
331
|
+
} else {
|
|
332
|
+
fs.unlinkSync(resolvedPath);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} catch(err) {}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
exports.getSupportFiles = (bsConfig, isA11y) => {
|
|
339
|
+
let extension = null;
|
|
340
|
+
try {
|
|
341
|
+
extension = bsConfig.run_settings.cypress_config_file.split('.').pop();
|
|
342
|
+
} catch (err) {}
|
|
343
|
+
let supportFile = '/**/cypress/support/**/*.{js,ts}';
|
|
344
|
+
let cleanupParams = {};
|
|
345
|
+
let userSupportFile = null;
|
|
346
|
+
try {
|
|
347
|
+
const completeCypressConfigFile = readCypressConfigFile(bsConfig)
|
|
348
|
+
let cypressConfigFile = {};
|
|
349
|
+
if (!utils.isUndefined(completeCypressConfigFile)) {
|
|
350
|
+
cypressConfigFile = !utils.isUndefined(completeCypressConfigFile.default) ? completeCypressConfigFile.default : completeCypressConfigFile
|
|
351
|
+
}
|
|
352
|
+
userSupportFile = cypressConfigFile.e2e?.supportFile !== null ? cypressConfigFile.e2e?.supportFile : cypressConfigFile.component?.supportFile !== null ? cypressConfigFile.component?.supportFile : cypressConfigFile.supportFile;
|
|
353
|
+
if(userSupportFile == false && extension) {
|
|
354
|
+
const supportFolderPath = path.join(process.cwd(), 'cypress', 'support');
|
|
355
|
+
if (!fs.existsSync(supportFolderPath)) {
|
|
356
|
+
fs.mkdirSync(supportFolderPath);
|
|
357
|
+
cleanupParams.deleteSupportDir = true;
|
|
358
|
+
}
|
|
359
|
+
const sanitizedExtension = extension.replace(/(\.\.\/|\.\/|\/\/)/g, '');
|
|
360
|
+
const supportFilePath = path.join(supportFolderPath, `tmpBstackSupportFile.${sanitizedExtension}`);
|
|
361
|
+
fs.writeFileSync(supportFilePath, "");
|
|
362
|
+
supportFile = `/cypress/support/tmpBstackSupportFile.${sanitizedExtension}`;
|
|
363
|
+
const currEnvVars = bsConfig.run_settings.system_env_vars;
|
|
364
|
+
const supportFileEnv = `CYPRESS_SUPPORT_FILE=${supportFile.substring(1)}`;
|
|
365
|
+
if(!currEnvVars) {
|
|
366
|
+
bsConfig.run_settings.system_env_vars = [supportFileEnv];
|
|
367
|
+
} else {
|
|
368
|
+
bsConfig.run_settings.system_env_vars = [...currEnvVars, supportFileEnv];
|
|
369
|
+
}
|
|
370
|
+
cleanupParams.deleteSupportFile = true;
|
|
371
|
+
} else if(typeof userSupportFile == 'string') {
|
|
372
|
+
if (userSupportFile.startsWith('${') && userSupportFile.endsWith('}')) {
|
|
373
|
+
/* Template strings to reference environment variables */
|
|
374
|
+
const envVar = userSupportFile.substring(2, userSupportFile.length - 1);
|
|
375
|
+
supportFile = process.env[envVar];
|
|
376
|
+
} else {
|
|
377
|
+
/* Single file / glob pattern */
|
|
378
|
+
supportFile = userSupportFile;
|
|
379
|
+
}
|
|
380
|
+
} else if(Array.isArray(userSupportFile)) {
|
|
381
|
+
supportFile = userSupportFile[0];
|
|
382
|
+
}
|
|
383
|
+
} catch (err) {}
|
|
384
|
+
if(supportFile && supportFile[0] != '/') supportFile = '/' + supportFile;
|
|
385
|
+
return {
|
|
386
|
+
supportFile,
|
|
387
|
+
cleanupParams: Object.keys(cleanupParams).length ? cleanupParams : null
|
|
388
|
+
};
|
|
389
|
+
}
|
package/bin/helpers/utils.js
CHANGED
|
@@ -561,6 +561,7 @@ exports.setSystemEnvs = (bsConfig) => {
|
|
|
561
561
|
|
|
562
562
|
try {
|
|
563
563
|
const accessibilityOptions = bsConfig.run_settings.accessibilityOptions;
|
|
564
|
+
envKeys['BROWSERSTACK_ACCESSIBILITY_DEBUG'] = process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG;
|
|
564
565
|
if (accessibilityOptions) {
|
|
565
566
|
Object.keys(accessibilityOptions).forEach(key => {
|
|
566
567
|
const a11y_env_key = `ACCESSIBILITY_${key.toUpperCase()}`
|
|
@@ -66,7 +66,15 @@ const httpsScreenshotsKeepAliveAgent = new https.Agent({
|
|
|
66
66
|
const supportFileCleanup = () => {
|
|
67
67
|
Object.keys(supportFileContentMap).forEach(file => {
|
|
68
68
|
try {
|
|
69
|
-
|
|
69
|
+
if(typeof supportFileContentMap[file] === 'object') {
|
|
70
|
+
let fileOrDirpath = file;
|
|
71
|
+
if(supportFileContentMap[file].deleteSupportDir) {
|
|
72
|
+
fileOrDirpath = path.join(process.cwd(), 'cypress', 'support');
|
|
73
|
+
}
|
|
74
|
+
helper.deleteSupportFileOrDir(fileOrDirpath);
|
|
75
|
+
} else {
|
|
76
|
+
fs.writeFileSync(file, supportFileContentMap[file], {encoding: 'utf-8'});
|
|
77
|
+
}
|
|
70
78
|
} catch(e) {
|
|
71
79
|
exports.debug(`Error while replacing file content for ${file} with it's original content with error : ${e}`, true, e);
|
|
72
80
|
}
|
|
@@ -241,29 +249,33 @@ const setEnvironmentVariablesForRemoteReporter = (BS_TESTOPS_JWT, BS_TESTOPS_BUI
|
|
|
241
249
|
process.env.OBSERVABILITY_LAUNCH_SDK_VERSION = OBSERVABILITY_LAUNCH_SDK_VERSION;
|
|
242
250
|
}
|
|
243
251
|
|
|
244
|
-
const getCypressCommandEventListener = () => {
|
|
245
|
-
return (
|
|
252
|
+
const getCypressCommandEventListener = (isJS) => {
|
|
253
|
+
return isJS ? (
|
|
246
254
|
`require('browserstack-cypress-cli/bin/testObservability/cypress');`
|
|
247
|
-
)
|
|
255
|
+
) : (
|
|
256
|
+
`import 'browserstack-cypress-cli/bin/testObservability/cypress'`
|
|
257
|
+
)
|
|
248
258
|
}
|
|
249
259
|
|
|
250
|
-
|
|
260
|
+
exports.setEventListeners = (bsConfig) => {
|
|
251
261
|
try {
|
|
252
|
-
const
|
|
253
|
-
|
|
262
|
+
const supportFilesData = helper.getSupportFiles(bsConfig, false);
|
|
263
|
+
if(!supportFilesData.supportFile) return;
|
|
264
|
+
glob(process.cwd() + supportFilesData.supportFile, {}, (err, files) => {
|
|
254
265
|
if(err) return exports.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
|
|
255
266
|
files.forEach(file => {
|
|
256
267
|
try {
|
|
257
268
|
if(!file.includes('commands.js')) {
|
|
258
269
|
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
|
|
259
270
|
|
|
271
|
+
let cypressCommandEventListener = getCypressCommandEventListener(file.includes('js'));
|
|
260
272
|
if(!defaultFileContent.includes(cypressCommandEventListener)) {
|
|
261
273
|
let newFileContent = defaultFileContent +
|
|
262
274
|
'\n' +
|
|
263
275
|
cypressCommandEventListener +
|
|
264
276
|
'\n'
|
|
265
277
|
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
|
|
266
|
-
supportFileContentMap[file] = defaultFileContent;
|
|
278
|
+
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent;
|
|
267
279
|
}
|
|
268
280
|
}
|
|
269
281
|
} catch(e) {
|
|
@@ -379,7 +391,6 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
|
|
|
379
391
|
exports.debug('Build creation successfull!');
|
|
380
392
|
process.env.BS_TESTOPS_BUILD_COMPLETED = true;
|
|
381
393
|
setEnvironmentVariablesForRemoteReporter(response.data.jwt, response.data.build_hashed_id, response.data.allow_screenshots, data.observability_version.sdkVersion);
|
|
382
|
-
// setEventListeners();
|
|
383
394
|
if(this.isBrowserstackInfra()) helper.setBrowserstackCypressCliDependency(user_config);
|
|
384
395
|
} catch(error) {
|
|
385
396
|
if(!error.errorType) {
|
|
@@ -804,6 +815,7 @@ exports.resolveModule = (module) => {
|
|
|
804
815
|
};
|
|
805
816
|
|
|
806
817
|
const getReRunSpecs = (rawArgs) => {
|
|
818
|
+
let finalArgs = rawArgs;
|
|
807
819
|
if (this.isTestObservabilitySession() && this.shouldReRunObservabilityTests()) {
|
|
808
820
|
let startIdx = -1, numEle = 0;
|
|
809
821
|
for(let idx=0; idx<rawArgs.length; idx++) {
|
|
@@ -816,10 +828,9 @@ const getReRunSpecs = (rawArgs) => {
|
|
|
816
828
|
}
|
|
817
829
|
}
|
|
818
830
|
if(startIdx != -1) rawArgs.splice(startIdx, numEle + 1);
|
|
819
|
-
|
|
820
|
-
} else {
|
|
821
|
-
return rawArgs;
|
|
831
|
+
finalArgs = [...rawArgs, '--spec', process.env.BROWSERSTACK_RERUN_TESTS];
|
|
822
832
|
}
|
|
833
|
+
return finalArgs.filter(item => item !== '--disable-test-observability' && item !== '--disable-browserstack-automation');
|
|
823
834
|
}
|
|
824
835
|
|
|
825
836
|
const getLocalSessionReporter = () => {
|