Skip to content

Commit 4aad557

Browse files
committed
chore: handle plugin not imported
1 parent f93465f commit 4aad557

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

bin/testObservability/cypress/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ const browserStackLog = (message) => {
1414
}
1515

1616
const shouldSkipCommand = (command) => {
17+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
18+
return true;
19+
}
1720
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))));
1821
}
1922

2023
Cypress.on('log:added', (log) => {
2124
return () => {
25+
if (shouldSkipCommand(command)) {
26+
return;
27+
}
2228
eventsQueue.push({
2329
task: 'test_observability_step',
2430
data: {
@@ -219,6 +225,11 @@ Cypress.Commands.add('fatal', (message, file) => {
219225

220226
beforeEach(() => {
221227
/* browserstack internal helper hook */
228+
229+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
230+
return;
231+
}
232+
222233
if (eventsQueue.length > 0) {
223234
eventsQueue.forEach(event => {
224235
cy.task(event.task, event.data, event.options);
@@ -230,6 +241,10 @@ beforeEach(() => {
230241

231242
afterEach(function() {
232243
/* browserstack internal helper hook */
244+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
245+
return;
246+
}
247+
233248
if (eventsQueue.length > 0) {
234249
eventsQueue.forEach(event => {
235250
cy.task(event.task, event.data, event.options);

bin/testObservability/plugin/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ const { connectIPCClient } = require('./ipcClient');
33
const { IPC_EVENTS } = require('../helper/constants');
44

55
const browserstackTestObservabilityPlugin = (on, config, callbacks) => {
6+
7+
try {
8+
config.env.BROWSERSTACK_O11Y_LOGS = 'true';
9+
process.env.BROWSERSTACK_O11Y_LOGS = 'true';
10+
} catch (err) {}
11+
612
connectIPCClient(config);
713

814
on('task', {

0 commit comments

Comments
 (0)