Skip to content

Commit 097c07e

Browse files
authored
Master merge
2 parents 497d4eb + bbcb4bc commit 097c07e

File tree

2 files changed

+93
-8
lines changed

2 files changed

+93
-8
lines changed

CODEOWNERS

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
# Default ownership for all other files
12
* @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

bin/testObservability/cypress/index.js

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Event listeners + custom commands for Cypress */
22

33
/* Used to detect Gherkin steps */
4+
const STEP_KEYWORDS = ['given', 'when', 'then', 'and', 'but', '*'];
45

56
let eventsQueue = [];
67
let testRunStarted = false;
@@ -18,20 +19,87 @@ const shouldSkipCommand = (command) => {
1819
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))));
1920
}
2021

21-
Cypress.on('log:added', (log) => {
22-
return () => {
23-
if (shouldSkipCommand(command)) {
24-
return;
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+
2673
eventsQueue.push({
2774
task: 'test_observability_step',
2875
data: {
29-
log,
30-
started_at: new Date().toISOString(),
31-
finished_at: new Date().toISOString()
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()
3283
},
3384
options: { log: false }
3485
});
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+
}
35103
}
36104
});
37105

0 commit comments

Comments
 (0)