browserstack-cypress-cli 1.36.1 → 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.
@@ -329,7 +329,7 @@ exports.setBrowserstackCypressCliDependency = (bsConfig) => {
329
329
  if (runSettings.npm_dependencies !== undefined &&
330
330
  typeof runSettings.npm_dependencies === 'object') {
331
331
  if (!("browserstack-cypress-cli" in runSettings.npm_dependencies)) {
332
- logger.warn("Missing browserstack-cypress-cli not found in npm_dependencies");
332
+ logger.warn("Missing browserstack-cypress-cli not found in npm_dependencies");
333
333
  runSettings.npm_dependencies['browserstack-cypress-cli'] = this.getAgentVersion() || "latest";
334
334
  logger.warn(`Adding browserstack-cypress-cli version ${runSettings.npm_dependencies['browserstack-cypress-cli']} in npm_dependencies`);
335
335
  }
@@ -1986,7 +1986,7 @@ exports.ensureBrowserstackCypressCliDependency = (npmDependencies) => {
1986
1986
  } catch (err) {
1987
1987
  logger.debug("Could not read package.json version, using 'latest'");
1988
1988
  }
1989
-
1989
+
1990
1990
  npmDependencies['browserstack-cypress-cli'] = version;
1991
1991
  logger.warn(`Adding browserstack-cypress-cli version ${version} in npm_dependencies`);
1992
1992
  };
@@ -1996,7 +1996,7 @@ exports.processAutoImportDependencies = (runSettings) => {
1996
1996
  exports.validateAutoImportConflict(runSettings);
1997
1997
 
1998
1998
  // Skip processing if auto_import_dev_dependencies is not enabled
1999
- if (!runSettings.auto_import_dev_dependencies) {
1999
+ if (runSettings.auto_import_dev_dependencies != true) {
2000
2000
  return;
2001
2001
  }
2002
2002
 
@@ -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: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
+
26
73
  eventsQueue.push({
27
74
  task: 'test_observability_step',
28
75
  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()
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
 
@@ -77,7 +77,7 @@ exports.setTestObservabilityVariables = (
77
77
  responseData.observability.options.allow_screenshots.toString(),
78
78
  requestData.framework_details.sdkVersion
79
79
  );
80
- helper.setBrowserstackCypressCliDependency(user_config);
80
+ if(user_config.run_settings.auto_import_dev_dependencies != true) helper.setBrowserstackCypressCliDependency(user_config);
81
81
  return [
82
82
  responseData.jwt,
83
83
  responseData.build_hashed_id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.36.1",
3
+ "version": "1.36.3",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {