froth-webdriverio-framework 0.1.32 → 0.1.34

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.
@@ -2,6 +2,7 @@ const login = require('./loginapi.js');
2
2
 
3
3
  // Function to get data from the API using the Bearer token
4
4
  async function getDataById(frothUrl, id) {
5
+ console.log("insiade get DataBy ID");
5
6
 
6
7
  if (id != 0) {
7
8
  const url = `https://${frothUrl}/api/testdata-retrieve/${id}`;
@@ -11,8 +12,6 @@ async function getDataById(frothUrl, id) {
11
12
  if (!token) {
12
13
  throw new Error('Login failed, no token obtained');
13
14
  }
14
- console.log('Fetching data with token:', token);
15
-
16
15
  const response = await fetch(url, {
17
16
  method: 'GET',
18
17
  headers: {
@@ -25,22 +24,28 @@ async function getDataById(frothUrl, id) {
25
24
  console.error('Data fetch failed response:', errorText);
26
25
  throw new Error(`HTTP error! status: ${response.status}`);
27
26
  }
28
-
29
27
  const data = await response.json();
30
- console.log('Data:', data);
31
28
  // Convert the key-value data to a JSON string
32
- const jsonData = JSON.stringify(data.key_value_data);
33
-
34
- // Log the JSON data to the console
35
- console.log("JSON Data:", jsonData);
29
+ const jsonData = data.key_value_data;
30
+ // Convert the array into an object with keys as property names
31
+ const buffer = jsonData.reduce((obj, item) => {
32
+ obj[item.key] = item.value;
33
+ return obj;
34
+ }, {});
35
+ // Set the buffer as an environment variable
36
+ const stringData = JSON.stringify(buffer);
37
+ process.env.BUFFER = stringData;
38
+ console.log('Buffer data:', process.env.BUFFER);
39
+ // const data1 = JSON.parse(process.env.BUFFER);
40
+ // console.log("Data1:", data1.sdfasd);
41
+ return stringData;
36
42
 
37
- process.env.BUFFER = JSON.stringify(jsonData);
38
43
 
39
- return jsonData;
40
44
  } catch (error) {
41
45
  console.error('Error fetching data:', error);
46
+ process.env.BUFFER = "0sdsf";
42
47
  }
43
- }else{
48
+ } else {
44
49
  console.error('Error fetching data: Invalid ID');
45
50
  }
46
51
 
@@ -49,4 +54,4 @@ module.exports = getDataById;
49
54
 
50
55
  // Execute the main function
51
56
 
52
- //console.log("Retrieved JSON Data from local storage:", getDataById("devapi.frothtestops.com",78, "asdfa"));
57
+ //console.log("Retrieved JSON Data from local storage:", getDataById("devapi.frothtestops.com", 78, "asdfa"));
@@ -1,76 +1,83 @@
1
1
  // Description: This file contains the common configuration for the webdriverio framework.
2
+ const readTestData = require('../api/readTestdata.js');
2
3
  const commonconfig = {
3
- /**
4
- * Gets executed before the suite starts (in Mocha/Jasmine only).
5
- * @param {object} suite suite details
6
- */
7
- beforeSuite: function (suite) {
8
- console.log("Running suite:", suite.title);
9
- },
10
-
11
- /**
12
- * Function to be executed before a test (in Mocha/Jasmine only)
13
- * @param {object} test test object
14
- * @param {object} context scope object the test was executed with
4
+ /**
5
+ * Gets executed before the suite starts (in Mocha/Jasmine only).
6
+ * @param {object} suite suite details
15
7
  */
16
- beforeTest: function (test, context) {
17
- console.log("Test Name:", test.title);
18
- console.log("Context Details:", context.title);
19
- console.log("File Name:", test.file);
20
-
21
- },
22
-
23
- afterStep: function (test, context, { error, result, duration, passed, retries }) {
24
- // if (passed) {
25
- // browser.takeScreenshot();
26
- // }
27
- },
28
- // afterTest: async function (test, context, { error, result, duration, passed, retries }) {
29
- // if (passed) { await browser.takeScreenshot() }
30
- // },
31
- /**
32
- * Function to be executed after a test (in Mocha/Jasmine only)
33
- * @param {object} test test object
34
- * @param {object} context scope object the test was executed with
35
- * @param {Error} result.error error object in case the test fails, otherwise `undefined`
36
- * @param {*} result.result return object of test function
37
- * @param {number} result.duration duration of test
38
- * @param {boolean} result.passed true if test has passed, otherwise false
39
- * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
40
- */
41
- afterTest: function (test, context, { error, result, duration, passed, retries }) {
42
- console.log(`Test '${test.title}' finished.`);
43
- console.log(`Duration: ${duration}ms`);
44
- console.log(`Passed: ${passed}`);
45
- if (error) {
46
- console.error(`Error: ${error.message}`);
47
- }
48
- console.log('---------------------------------------');
49
- },
50
- /**
51
- * Hook that gets executed after the suite has ended (in Mocha/Jasmine only).
52
- * @param {object} suite suite details
53
- */
54
- afterSuite: function (suite) {
55
- console.log(`Test suite '${suite.title}' has ended.`);
56
- },
57
- /**
58
- * Gets executed after all tests are done. You still have access to all global variables from
59
- * the test.
60
- * @param {number} result 0 - test pass, 1 - test fail
61
- * @param {Array.<Object>} capabilities list of capabilities details
62
- * @param {Array.<String>} specs List of spec file paths that ran
63
- */
64
- after: function (result, capabilities, specs) {
65
- console.log('All tests are done.');
66
- console.log(`Result: ${result === 0 ? 'Pass' : 'Fail'}`);
67
- console.log('Capabilities:');
68
- console.log(capabilities);
69
- console.log('Specs:');
70
- console.log(specs);
71
- },
72
-
73
- };
74
-
75
- module.exports = commonconfig;
76
-
8
+ beforeSuite: function (suite) {
9
+ try{
10
+ console.log("Running suite:", suite.title);
11
+ console.log("Reading test data from the API");
12
+ // readTestData(process.env.organisation_url, process.env.testdata_id);
13
+
14
+ }catch(e){
15
+ console.log("Error in beforeSuite:", e);
16
+ }
17
+ },
18
+
19
+ /**
20
+ * Function to be executed before a test (in Mocha/Jasmine only)
21
+ * @param {object} test test object
22
+ * @param {object} context scope object the test was executed with
23
+ */
24
+ beforeTest: function (test, context) {
25
+ console.log("Test Name:", test.title);
26
+ console.log("Context Details:", context.title);
27
+ console.log("File Name:", test.file);
28
+
29
+ },
30
+
31
+ afterStep: function (test, context, { error, result, duration, passed, retries }) {
32
+ // if (passed) {
33
+ // browser.takeScreenshot();
34
+ // }
35
+ },
36
+ // afterTest: async function (test, context, { error, result, duration, passed, retries }) {
37
+ // if (passed) { await browser.takeScreenshot() }
38
+ // },
39
+ /**
40
+ * Function to be executed after a test (in Mocha/Jasmine only)
41
+ * @param {object} test test object
42
+ * @param {object} context scope object the test was executed with
43
+ * @param {Error} result.error error object in case the test fails, otherwise `undefined`
44
+ * @param {*} result.result return object of test function
45
+ * @param {number} result.duration duration of test
46
+ * @param {boolean} result.passed true if test has passed, otherwise false
47
+ * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
48
+ */
49
+ afterTest: function (test, context, { error, result, duration, passed, retries }) {
50
+ console.log(`Test '${test.title}' finished.`);
51
+ console.log(`Duration: ${duration}ms`);
52
+ console.log(`Passed: ${passed}`);
53
+ if (error) {
54
+ console.error(`Error: ${error.message}`);
55
+ }
56
+ console.log('---------------------------------------');
57
+ },
58
+ /**
59
+ * Hook that gets executed after the suite has ended (in Mocha/Jasmine only).
60
+ * @param {object} suite suite details
61
+ */
62
+ afterSuite: function (suite) {
63
+ console.log(`Test suite '${suite.title}' has ended.`);
64
+ },
65
+ /**
66
+ * Gets executed after all tests are done. You still have access to all global variables from
67
+ * the test.
68
+ * @param {number} result 0 - test pass, 1 - test fail
69
+ * @param {Array.<Object>} capabilities list of capabilities details
70
+ * @param {Array.<String>} specs List of spec file paths that ran
71
+ */
72
+ after: function (result, capabilities, specs) {
73
+ console.log('All tests are done.');
74
+ console.log(`Result: ${result === 0 ? 'Pass' : 'Fail'}`);
75
+ console.log('Capabilities:');
76
+ console.log(capabilities);
77
+ console.log('Specs:');
78
+ console.log(specs);
79
+ },
80
+
81
+ };
82
+
83
+ module.exports = commonconfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "readme": "WendriverIO Integration with [BrowserStack]",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",