froth-webdriverio-framework 0.1.32 → 0.1.33

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