froth-webdriverio-framework 4.0.58 → 4.0.59

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.
@@ -3,37 +3,70 @@ const fs = require('fs');
3
3
  const yaml = require('js-yaml');
4
4
  const path = require('path');
5
5
  const commonconfig = require('./commonconfig');
6
- const exeDetails = require('../froth_api_calls/getexecutionDetails');
7
- let capabilities;
8
- let SUITE_FILE;
9
- const resultdetails = {
10
- comments: [],
11
- excution_status: null, // Pass/Fail
12
- excution_time: null, // Execution time in milliseconds
13
- };
14
-
15
-
16
6
  console.log('=====wdios common config===== ');
7
+
17
8
  // Select platform at runtime
18
9
  const PLATFORM = process.env.PLATFORM || 'browserstack';
10
+ const configFile = process.env.YML_NAME || '../ymls/browserstack/android/android_caps.yml';
19
11
  console.log('====>PLATFORM:', PLATFORM);
20
-
21
12
  // Load YAML file
22
- function loadCapabilities() {
23
- const configFile = process.env.YML_NAME;
13
+ //const capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
14
+
15
+ let capabilities;
16
+
17
+ try {
18
+ capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
19
+ } catch (e) {
20
+ const errorMsg = `The capability file does not exist in the currently configured repository at path: ${path.resolve(process.cwd(), configFile)}: ${e.message},Please update the Capability by editing the file`;
21
+ console.error(errorMsg);
22
+ resultdetails.comments.push(errorMsg);
23
+
24
24
  try {
25
- return yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
26
- } catch (e) {
27
- throw new Error(`Capability file missing or unreadable at ${process.env.YML_NAME}: ${e.message}`);
25
+ exeDetails.updateExecuitonDetails(
26
+ process.env.ORGANISATION_DOMAIN_URL,
27
+ process.env.API_TOKEN,
28
+ process.env.EXECUTION_ID,
29
+ resultdetails
30
+ );
31
+ setTimeout(() => {
32
+ console.log("30 seconds passed.");
33
+ // You can call your API or exit the process here
34
+ }, 30000);
35
+ console.log('Execution details updated successfully.');
36
+ } catch (err) {
37
+ console.error('Failed to update execution details:', err.message);
28
38
  }
39
+ process.exit(1);
29
40
  }
30
- function checkSuiteFile() {
31
- SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
32
- console.log('====>SUITE_FILE:', SUITE_FILE);
33
- if (!fs.existsSync(SUITE_FILE)) {
34
- throw new Error(`Suite file does not exist at ${SUITE_FILE}`);
41
+ console.log('====>capabilities:', capabilities);
42
+
43
+ const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
44
+ console.log('====>SUITE_FILE:', SUITE_FILE);
45
+
46
+ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
47
+ let errorMsg = `The suite file does not exist in the currently configured repository at path: ${SUITE_FILE}. Please update the SUITE by editing the file`;
48
+
49
+ console.error(errorMsg);
50
+ resultdetails.comments.push(errorMsg);
51
+
52
+ // Fire API call in background (non-blocking)
53
+
54
+ try {
55
+ exeDetails.updateExecuitonDetails(
56
+ process.env.ORGANISATION_DOMAIN_URL,
57
+ process.env.API_TOKEN,
58
+ process.env.EXECUTION_ID,
59
+ resultdetails
60
+ );
61
+ setTimeout(() => {
62
+ console.log("30 seconds passed.");
63
+ // You can call your API or exit the process here
64
+ }, 30000);
65
+ console.log('Execution details updated successfully.');
66
+ } catch (err) {
67
+ console.error('Failed to update execution details:', err.message);
35
68
  }
36
- return SUITE_FILE;
69
+ process.exit(1);
37
70
  }
38
71
 
39
72
  function setupPrerequisites() {
@@ -45,96 +78,14 @@ function setupPrerequisites() {
45
78
 
46
79
  console.log('capabilities.platformName:', capabilities.platformName ?? 'web');
47
80
 
48
- process.env.BS_SESSION_TYPE = ['android', 'ios'].includes(capabilities.platformName) ? 'app-automate' : 'automate';
81
+ process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
49
82
  capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
50
83
 
51
84
  }
52
85
 
53
86
  }
54
- // let capabilities;
55
-
56
- // try {
57
- // capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
58
- // } catch (e) {
59
- // const errorMsg = `The capability file does not exist in the currently configured repository at path: ${path.resolve(process.cwd(), configFile)}: ${e.message},Please update the Capability by editing the file`;
60
- // console.error(errorMsg);
61
- // resultdetails.comments.push(errorMsg);
62
87
 
63
- // try {
64
- // await exeDetails.updateExecuitonDetails(
65
- // process.env.ORGANISATION_DOMAIN_URL,
66
- // process.env.API_TOKEN,
67
- // process.env.EXECUTION_ID,
68
- // resultdetails
69
- // );
70
- // console.log('Execution details updated successfully.');
71
- // } catch (err) {
72
- // console.error('Failed to update execution details:', err.message);
73
- // }
74
- // process.exit(1);
75
- // }
76
-
77
- //console.log('====>capabilities:', capabilities);
78
-
79
-
80
-
81
- // if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
82
- // let errorMsg = `The suite file does not exist in the currently configured repository at path: ${SUITE_FILE}. Please update the SUITE by editing the file`;
83
-
84
- // console.error(errorMsg);
85
- // resultdetails.comments.push(errorMsg);
86
-
87
- // // Fire API call in background (non-blocking)
88
-
89
- // try {
90
- // await exeDetails.updateExecuitonDetails(
91
- // process.env.ORGANISATION_DOMAIN_URL,
92
- // process.env.API_TOKEN,
93
- // process.env.EXECUTION_ID,
94
- // resultdetails
95
- // );
96
- // console.log('Execution details updated successfully.');
97
- // } catch (err) {
98
- // console.error('Failed to update execution details:', err.message);
99
- // }
100
- // process.exit(1);
101
- // }
102
-
103
-
104
- // Now main synchronous part:
105
-
106
-
107
- try {
108
- capabilities = loadCapabilities();
109
- checkSuiteFile();
110
- setupPrerequisites();
111
- } catch (err) {
112
- // Synchronous throw to fail fast
113
- // Update execution details async outside or in CI pipeline
114
- console.error(err.message);
115
-
116
- resultdetails.comments.push(err.message);
117
- resultdetails.excution_status = 'FAIL';
118
-
119
- //wait for somtime before calling this methof
120
-
121
- exeDetails.updateExecuitonDetails(
122
- process.env.ORGANISATION_DOMAIN_URL,
123
- process.env.API_TOKEN,
124
- process.env.EXECUTION_ID,
125
- resultdetails
126
- ).catch(err => {
127
- console.error('Failed to update execution details:', err.message);
128
- });
129
-
130
- setTimeout(() => {
131
- console.log('Updating execution details...');
132
- }
133
- , 30000);
134
- process.exit(1);
135
- }
136
-
137
- //await setupPrerequisites();
88
+ const specificConfig = setupPrerequisites();
138
89
 
139
90
 
140
91
  exports.config = deepmerge(commonconfig,
@@ -173,6 +124,4 @@ exports.config = deepmerge(commonconfig,
173
124
  ui: 'bdd',
174
125
  timeout: 300000
175
126
  }
176
- });
177
-
178
-
127
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "4.0.58",
3
+ "version": "4.0.59",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",