browserstack-cypress-cli 1.36.3 → 1.36.4
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/CODEOWNERS
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
+
# Default ownership for all other files
|
|
1
2
|
* @browserstack/automate-dev
|
|
3
|
+
|
|
4
|
+
# Ownership for the CODEOWNERS file
|
|
5
|
+
CODEOWNERS @browserstack/sdk-dev @browserstack/automate-dev
|
|
6
|
+
|
|
7
|
+
# Ownership for SDK-related files
|
|
8
|
+
bin/testhub/ @browserstack/sdk-dev
|
|
9
|
+
bin/accessibility-automation/ @browserstack/sdk-dev
|
|
10
|
+
bin/testObservability/ @browserstack/sdk-dev
|
|
11
|
+
|
|
12
|
+
# Shared ownership for certain files
|
|
13
|
+
/.gitignore @browserstack/sdk-dev @browserstack/automate-dev
|
|
14
|
+
/package.json @browserstack/sdk-dev @browserstack/automate-dev
|
|
15
|
+
bin/commands/runs.js @browserstack/sdk-dev @browserstack/automate-dev
|
|
16
|
+
bin/helpers/helper.js @browserstack/sdk-dev @browserstack/automate-dev
|
|
17
|
+
bin/helpers/logger.js @browserstack/sdk-dev @browserstack/automate-dev
|
|
18
|
+
bin/helpers/utils.js @browserstack/sdk-dev @browserstack/automate-dev
|
|
@@ -27,6 +27,7 @@ Cypress.on('log:changed', (attrs) => {
|
|
|
27
27
|
|
|
28
28
|
if (attrs.name === 'assert') {
|
|
29
29
|
const assertMessage = (attrs.message || '')
|
|
30
|
+
const actualLocation = (attrs.testId === attrs.hookId) ? 'test' : 'hook';
|
|
30
31
|
|
|
31
32
|
eventsQueue.push({
|
|
32
33
|
task: 'test_observability_command',
|
|
@@ -36,11 +37,13 @@ Cypress.on('log:changed', (attrs) => {
|
|
|
36
37
|
attributes: {
|
|
37
38
|
id: attrs.id,
|
|
38
39
|
name: 'assert',
|
|
40
|
+
testId: attrs.testId,
|
|
41
|
+
hookId: attrs.hookId,
|
|
39
42
|
args: [assertMessage]
|
|
40
43
|
},
|
|
41
44
|
state: 'pending',
|
|
42
45
|
started_at: new Date(attrs.createdAtTimestamp).toISOString(),
|
|
43
|
-
location:
|
|
46
|
+
location: actualLocation
|
|
44
47
|
}
|
|
45
48
|
},
|
|
46
49
|
options: { log: false }
|
|
@@ -54,11 +57,13 @@ Cypress.on('log:changed', (attrs) => {
|
|
|
54
57
|
attributes: {
|
|
55
58
|
id: attrs.id,
|
|
56
59
|
name: 'assert',
|
|
60
|
+
testId: attrs.testId,
|
|
61
|
+
hookId: attrs.hookId,
|
|
57
62
|
args: [assertMessage]
|
|
58
63
|
},
|
|
59
64
|
state: attrs.state,
|
|
60
65
|
finished_at: new Date(attrs.updatedAtTimestamp).toISOString(),
|
|
61
|
-
location:
|
|
66
|
+
location: actualLocation
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
options: { log: false }
|
|
@@ -77,6 +77,7 @@ class MyReporter {
|
|
|
77
77
|
this.hooksStarted = {};
|
|
78
78
|
this.beforeHooks = [];
|
|
79
79
|
this.testIdMap = {};
|
|
80
|
+
this.internalIdMap = {};
|
|
80
81
|
this.platformDetailsMap = {};
|
|
81
82
|
this.runStatusMarkedHash = {};
|
|
82
83
|
this.haveSentBuildUpdate = false;
|
|
@@ -101,6 +102,8 @@ class MyReporter {
|
|
|
101
102
|
delete this.runStatusMarkedHash[hook.hookAnalyticsId];
|
|
102
103
|
hook.hookAnalyticsId = uuidv4();
|
|
103
104
|
}
|
|
105
|
+
|
|
106
|
+
if (hook.id) this.internalIdMap[hook.id] = hook.hookAnalyticsId;
|
|
104
107
|
debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN for uuid: ${hook.hookAnalyticsId}`);
|
|
105
108
|
hook.hook_started_at = (new Date()).toISOString();
|
|
106
109
|
hook.started_at = (new Date()).toISOString();
|
|
@@ -132,7 +135,11 @@ class MyReporter {
|
|
|
132
135
|
}
|
|
133
136
|
})
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
.on(EVENT_SUITE_END, (suite) => {
|
|
139
|
+
if (suite.root) {
|
|
140
|
+
debugOnConsole(`[MOCHA EVENT] EVENT_SUITE_END for root suite`);
|
|
141
|
+
this.internalIdMap = {};
|
|
142
|
+
}
|
|
136
143
|
})
|
|
137
144
|
|
|
138
145
|
.on(EVENT_TEST_PASS, async (test) => {
|
|
@@ -213,12 +220,29 @@ class MyReporter {
|
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
isInternalHook(hook) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
if (!hook || !hook.body) return false;
|
|
224
|
+
|
|
225
|
+
const body = hook.body.toString();
|
|
226
|
+
|
|
227
|
+
// Keep your existing check for BrowserStack internal helpers
|
|
228
|
+
if (body.includes('/* browserstack internal helper hook */')) {
|
|
229
|
+
return true;
|
|
220
230
|
}
|
|
221
231
|
|
|
232
|
+
// Filter duplicate hooks caused by @badeball
|
|
233
|
+
const isBadeballInternal =
|
|
234
|
+
body.includes('beforeEachHandler.call(this, context)') ||
|
|
235
|
+
body.includes('afterEachHandler.call(this, context)') ||
|
|
236
|
+
body.includes('beforeHandler.call(this, context)') ||
|
|
237
|
+
body.includes('afterHandler.call(this, context)');
|
|
238
|
+
|
|
239
|
+
if (isBadeballInternal) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
222
246
|
async startHttpServer() {
|
|
223
247
|
if(this.httpServer !== null) return;
|
|
224
248
|
|
|
@@ -313,6 +337,8 @@ class MyReporter {
|
|
|
313
337
|
this.current_test = test;
|
|
314
338
|
test.retryOf = null;
|
|
315
339
|
test.testAnalyticsId = uuidv4();
|
|
340
|
+
if (test.id) this.internalIdMap[test.id] = test.testAnalyticsId;
|
|
341
|
+
debugOnConsole(`[MOCHA EVENT] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`);
|
|
316
342
|
test.started_at = (new Date()).toISOString();
|
|
317
343
|
test.test_started_at = test.started_at;
|
|
318
344
|
if(test._currentRetry > 0 && lastTest && lastTest.title == test.title) {
|
|
@@ -332,6 +358,14 @@ class MyReporter {
|
|
|
332
358
|
|
|
333
359
|
uploadTestSteps = async (shouldClearCurrentSteps = true, cypressSteps = null) => {
|
|
334
360
|
const currentTestSteps = cypressSteps ? cypressSteps : JSON.parse(JSON.stringify(this.currentTestSteps));
|
|
361
|
+
|
|
362
|
+
if(shouldClearCurrentSteps && !cypressSteps) {
|
|
363
|
+
this.currentTestSteps = [];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (!currentTestSteps || currentTestSteps.length === 0) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
335
369
|
/* TODO - Send as test logs */
|
|
336
370
|
const allStepsAsLogs = [];
|
|
337
371
|
currentTestSteps.forEach(step => {
|
|
@@ -354,7 +388,6 @@ class MyReporter {
|
|
|
354
388
|
event_type: 'LogCreated',
|
|
355
389
|
logs: allStepsAsLogs
|
|
356
390
|
});
|
|
357
|
-
if(shouldClearCurrentSteps) this.currentTestSteps = [];
|
|
358
391
|
}
|
|
359
392
|
|
|
360
393
|
sendTestRunEvent = async (test, err = undefined, customFinished=false, eventType = "TestRunFinished") => {
|
|
@@ -704,6 +737,9 @@ class MyReporter {
|
|
|
704
737
|
return;
|
|
705
738
|
}
|
|
706
739
|
|
|
740
|
+
const cypressTestId = command.testId || command.attributes?.testId;
|
|
741
|
+
const cypressHookId = command.hookId || command.attributes?.hookId;
|
|
742
|
+
|
|
707
743
|
const currentStepObj = {
|
|
708
744
|
id: command.attributes.id,
|
|
709
745
|
text: 'cy.' + command.attributes.name + '(' + this.getFormattedArgs(command.attributes.args) + ')',
|
|
@@ -711,8 +747,11 @@ class MyReporter {
|
|
|
711
747
|
finished_at: null,
|
|
712
748
|
duration: null,
|
|
713
749
|
result: 'pending',
|
|
714
|
-
test_run_uuid: command.location === 'test'
|
|
715
|
-
|
|
750
|
+
test_run_uuid: command.location === 'test'
|
|
751
|
+
? (this.internalIdMap[cypressTestId] || this.current_test?.testAnalyticsId) : null,
|
|
752
|
+
|
|
753
|
+
hook_run_uuid : command.location === 'hook'
|
|
754
|
+
? (this.internalIdMap[cypressHookId] || this.current_hook?.hookAnalyticsId) : null
|
|
716
755
|
};
|
|
717
756
|
if(currentStepObj.hook_run_uuid && currentStepObj.test_run_uuid) delete currentStepObj.test_run_uuid;
|
|
718
757
|
this.currentTestSteps = [
|
|
@@ -735,6 +774,10 @@ class MyReporter {
|
|
|
735
774
|
|
|
736
775
|
if(!stepUpdated) {
|
|
737
776
|
/* COMMAND_END reported before COMMAND_START */
|
|
777
|
+
|
|
778
|
+
const cypressTestId = command.testId || command.attributes?.testId;
|
|
779
|
+
const cypressHookId = command.hookId || command.attributes?.hookId;
|
|
780
|
+
|
|
738
781
|
const currentStepObj = {
|
|
739
782
|
id: command.attributes.id,
|
|
740
783
|
text: 'cy.' + command.attributes.name + '(' + this.getFormattedArgs(command.attributes.args) + ')',
|
|
@@ -742,8 +785,11 @@ class MyReporter {
|
|
|
742
785
|
finished_at: new Date().toISOString(),
|
|
743
786
|
duration: 0,
|
|
744
787
|
result: command.state,
|
|
745
|
-
test_run_uuid: command.location === 'test'
|
|
746
|
-
|
|
788
|
+
test_run_uuid: command.location === 'test'
|
|
789
|
+
? (this.internalIdMap[cypressTestId] || this.current_test?.testAnalyticsId) : null,
|
|
790
|
+
|
|
791
|
+
hook_run_uuid : command.location === 'hook'
|
|
792
|
+
? (this.internalIdMap[cypressHookId] || this.current_hook?.hookAnalyticsId) : null
|
|
747
793
|
};
|
|
748
794
|
if(currentStepObj.hook_run_uuid && currentStepObj.test_run_uuid) delete currentStepObj.test_run_uuid;
|
|
749
795
|
this.currentTestSteps = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserstack-cypress-cli",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.4",
|
|
4
4
|
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"async": "3.2.3",
|
|
17
17
|
"axios": "^1.7.7",
|
|
18
18
|
"axios-retry": "^3.5.0",
|
|
19
|
-
"browserstack-local": "1.5.
|
|
20
|
-
"https-proxy-agent": "^5.0.1",
|
|
19
|
+
"browserstack-local": "^1.5.12",
|
|
21
20
|
"chalk": "4.1.2",
|
|
22
21
|
"cli-progress": "^3.10.0",
|
|
23
22
|
"decompress": "4.2.1",
|
|
@@ -29,6 +28,7 @@
|
|
|
29
28
|
"git-repo-info": "^2.1.1",
|
|
30
29
|
"gitconfiglocal": "^2.1.0",
|
|
31
30
|
"glob": "^7.2.0",
|
|
31
|
+
"https-proxy-agent": "^5.0.1",
|
|
32
32
|
"mkdirp": "1.0.4",
|
|
33
33
|
"mocha": "^10.2.0",
|
|
34
34
|
"node-ipc": "9.1.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"nyc": "15.1.0",
|
|
58
58
|
"proxyquire": "2.1.3",
|
|
59
|
-
"rewire": "
|
|
59
|
+
"rewire": "^9.0.1",
|
|
60
60
|
"sinon": "9.2.4"
|
|
61
61
|
}
|
|
62
62
|
}
|