browserstack-cypress-cli 1.36.2 → 1.36.3
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
3
3
|
/* Used to detect Gherkin steps */
|
|
4
|
+
const STEP_KEYWORDS = ['given', 'when', 'then', 'and', 'but', '*'];
|
|
4
5
|
|
|
5
6
|
let eventsQueue = [];
|
|
6
7
|
let testRunStarted = false;
|
|
@@ -18,20 +19,87 @@ const shouldSkipCommand = (command) => {
|
|
|
18
19
|
return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log', 'test_observability_log'].some(event => command.attributes.args.includes(event))));
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
Cypress.on('log:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
Cypress.on('log:changed', (attrs) => {
|
|
23
|
+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
|
|
24
|
+
if (!attrs) return;
|
|
25
|
+
if (!attrs.createdAtTimestamp || !attrs.updatedAtTimestamp) return;
|
|
26
|
+
if (attrs.state !== 'passed' && attrs.state !== 'failed') return;
|
|
27
|
+
|
|
28
|
+
if (attrs.name === 'assert') {
|
|
29
|
+
const assertMessage = (attrs.message || '')
|
|
30
|
+
|
|
31
|
+
eventsQueue.push({
|
|
32
|
+
task: 'test_observability_command',
|
|
33
|
+
data: {
|
|
34
|
+
type: 'COMMAND_START',
|
|
35
|
+
command: {
|
|
36
|
+
attributes: {
|
|
37
|
+
id: attrs.id,
|
|
38
|
+
name: 'assert',
|
|
39
|
+
args: [assertMessage]
|
|
40
|
+
},
|
|
41
|
+
state: 'pending',
|
|
42
|
+
started_at: new Date(attrs.createdAtTimestamp).toISOString(),
|
|
43
|
+
location: testRunStarted ? 'test' : 'hook'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
options: { log: false }
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
eventsQueue.push({
|
|
50
|
+
task: 'test_observability_command',
|
|
51
|
+
data: {
|
|
52
|
+
type: 'COMMAND_END',
|
|
53
|
+
command: {
|
|
54
|
+
attributes: {
|
|
55
|
+
id: attrs.id,
|
|
56
|
+
name: 'assert',
|
|
57
|
+
args: [assertMessage]
|
|
58
|
+
},
|
|
59
|
+
state: attrs.state,
|
|
60
|
+
finished_at: new Date(attrs.updatedAtTimestamp).toISOString(),
|
|
61
|
+
location: testRunStarted ? 'test' : 'hook'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
options: { log: false }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const keyword = (attrs.displayName || attrs.name || '').trim();
|
|
69
|
+
|
|
70
|
+
if (STEP_KEYWORDS.includes(keyword.toLowerCase())) {
|
|
71
|
+
const text = (attrs.message || '')
|
|
72
|
+
|
|
26
73
|
eventsQueue.push({
|
|
27
74
|
task: 'test_observability_step',
|
|
28
75
|
data: {
|
|
29
|
-
log
|
|
30
|
-
|
|
31
|
-
|
|
76
|
+
log: {
|
|
77
|
+
name: 'step',
|
|
78
|
+
chainerId: attrs.chainerId,
|
|
79
|
+
consoleProps: { step: { keyword, text } }
|
|
80
|
+
},
|
|
81
|
+
started_at: new Date(attrs.createdAtTimestamp).toISOString(),
|
|
82
|
+
finished_at: new Date(attrs.updatedAtTimestamp).toISOString()
|
|
32
83
|
},
|
|
33
84
|
options: { log: false }
|
|
34
85
|
});
|
|
86
|
+
|
|
87
|
+
if (attrs.state === 'failed') {
|
|
88
|
+
eventsQueue.push({
|
|
89
|
+
task: 'test_observability_step',
|
|
90
|
+
data: {
|
|
91
|
+
log: {
|
|
92
|
+
name: 'then',
|
|
93
|
+
type: 'child',
|
|
94
|
+
chainerId: attrs.chainerId,
|
|
95
|
+
state: attrs.state,
|
|
96
|
+
err: attrs.err
|
|
97
|
+
},
|
|
98
|
+
finished_at: new Date(attrs.updatedAtTimestamp).toISOString()
|
|
99
|
+
},
|
|
100
|
+
options: { log: false }
|
|
101
|
+
});
|
|
102
|
+
}
|
|
35
103
|
}
|
|
36
104
|
});
|
|
37
105
|
|