froth-webdriverio-framework 4.0.35 → 4.0.36

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.
@@ -18,9 +18,8 @@ async function assertText(elementSelector, expectedText) {
18
18
  let annotationMessage = `Assertion failed. Expected text: ${expectedText}.`;
19
19
  await amendToBrowserstack(annotationMessage, "error");
20
20
  if (!browser.testErrors) browser.testErrors = [];
21
- browser.testErrors.push(`Assertion failed.: ${error.message}`);
22
-
23
- // assert.fail(`Text assertion failed: ${error.message}`);
21
+ // browser.testErrors.push(`Assertion failed.: ${error.message}`);
22
+ assert.fail(`Text assertion failed: ${error.message}`);
24
23
  }
25
24
 
26
25
 
@@ -29,8 +28,8 @@ async function assertText(elementSelector, expectedText) {
29
28
  let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
30
29
  await amendToBrowserstack(annotationMessage, "error");
31
30
  if (!browser.testErrors) browser.testErrors = [];
32
- browser.testErrors.push(`Assertion failed.: ${error.message}`);
33
- // assert.fail(`Text assertion failed: ${error.message}`);
31
+ // browser.testErrors.push(`Assertion failed.: ${error.message}`);
32
+ assert.fail(`Text assertion failed: ${error.message}`);
34
33
  // throw error;
35
34
  }
36
35
 
@@ -56,16 +55,16 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
56
55
  await amendToBrowserstack(annotationMessage, "error");
57
56
  console.log("Assertion failed. Expected text: ", expectedText);
58
57
  if (!browser.testErrors) browser.testErrors = [];
59
- browser.testErrors.push(`Assertion failed.: ${error.message}`);
60
- // assert.fail(`Text assertion failed: ${error.message}`);
58
+ // browser.testErrors.push(`Assertion failed.: ${error.message}`);
59
+ assert.fail(`Text assertion failed: ${error.message}`);
61
60
  }
62
61
  } catch (error) {
63
62
  console.error('Error occurred while verifying text:', error);
64
63
  let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
65
64
  await amendToBrowserstack(annotationMessage, "error");
66
65
  if (!browser.testErrors) browser.testErrors = [];
67
- browser.testErrors.push(`Assertion failed.: ${error.message}`);
68
- // assert.fail(`Text assertion failed: ${error.message}`);
66
+ // browser.testErrors.push(`Assertion failed.: ${error.message}`);
67
+ assert.fail(`Text assertion failed: ${error.message}`);
69
68
  }
70
69
 
71
70
 
@@ -3,7 +3,6 @@ const url = require('url');
3
3
  const fs = require('fs');
4
4
  const { LocalStorage } = require('node-localstorage');
5
5
  global.BUFFER = new LocalStorage('./storage');
6
- global.suite_info = null;
7
6
  const setAllDetails = require("./setallDatailinBuffer")
8
7
  const exeDetails = require("../froth_api_calls/getexecutionDetails")
9
8
  const getBSSessionDetails = require("../froth_api_calls/browsersatckSessionInfo").getBSSessionDetails;
@@ -48,6 +47,7 @@ const commonconfig = {
48
47
  // Perform any setup or pre-test actions here
49
48
  console.log("specdat:", specs);
50
49
  console.log("length:", specs.length);
50
+ //checking the syntax error in the test files
51
51
  for (const fileUrl of specs) {
52
52
  const filePath = url.fileURLToPath(fileUrl); // convert file:// URL to file path
53
53
  try {
@@ -74,7 +74,7 @@ const commonconfig = {
74
74
  );
75
75
  process.exit(1);
76
76
  }
77
-
77
+ // set the capability like media and app and bs local
78
78
  if (process.env.PLATFORM === 'browserstack') {
79
79
  /// console.log("capabilities:", capabilities);
80
80
  capabilities.browserstackLocal = process.env.BROWSERSTACK_LOCAL;
@@ -142,7 +142,7 @@ const commonconfig = {
142
142
 
143
143
  console.log('==== BEFORE TEST HOOK ====');
144
144
  console.log(`====> Test Started '${test.title}'`);
145
- browser.testErrors = [];
145
+ // browser.testErrors = [];
146
146
  // console.log("File Name:", test.file);
147
147
 
148
148
  },
@@ -171,30 +171,30 @@ const commonconfig = {
171
171
  let scriptresult = "NOT RUN";
172
172
  // Default assumption: test passed (unless soft assertion failed)
173
173
  let finalPassed = passed;
174
- let combinedError = error;
174
+ // let combinedError = error;
175
175
 
176
176
  // Check soft assertion failures
177
- const softErrors = browser.testErrors || [];
178
- if (softErrors.length > 0) {
179
- finalPassed = false; // Override status
180
- const softErrorMessage = `Soft assertion errors: ${softErrors.join('<br>')}`;
181
- console.log('====> Soft Assertion Failures Detected:\n' + softErrorMessage);
182
-
183
- // Log in resultdetails
184
- resultdetails.comments.push(`${test.title} - failed: ${softErrorMessage}`);
185
- global.__SOFT_FAIL__ = true;
186
- // Overwrite the error param so your logic can pick it up
187
- combinedError = new Error(softErrorMessage);
188
- }
189
- if (finalPassed) {
177
+ // const softErrors = browser.testErrors || [];
178
+ // if (softErrors.length > 0) {
179
+ // finalPassed = false; // Override status
180
+ // const softErrorMessage = `Soft assertion errors: ${softErrors.join('<br>')}`;
181
+ // console.log('====> Soft Assertion Failures Detected:\n' + softErrorMessage);
182
+
183
+ // // Log in resultdetails
184
+ // resultdetails.comments.push(`${test.title} - failed: ${softErrorMessage}`);
185
+ // global.__SOFT_FAIL__ = true;
186
+ // // Overwrite the error param so your logic can pick it up
187
+ // combinedError = new Error(softErrorMessage);
188
+ // }
189
+ if (passed) {
190
190
  scriptresult = "PASSED"
191
191
  resultdetails.comments.push(`${test.title} - passed`);
192
192
  }
193
- else if (!finalPassed || combinedError) {
193
+ else if (!finalPassed || error) {
194
194
  scriptresult = "FAILED"
195
- console.log(`====> Failed or error while executing the test: ${combinedError ? combinedError.message : "Test failed"}`);
195
+ console.log(`====> Failed or error while executing the test: ${error ? error.message : "Test failed"}`);
196
196
  if (!resultdetails.comments.some(comment => typeof comment === 'string' && comment.includes(test.title)))
197
- resultdetails.comments.push(`${test.title} - failed: ${combinedError ? combinedError.message : "Test failed"}`);
197
+ resultdetails.comments.push(`${test.title} - failed: ${error ? error.message : "Test failed"}`);
198
198
 
199
199
  }
200
200
 
@@ -212,9 +212,9 @@ const commonconfig = {
212
212
  jwtScript.platform.toLowerCase(),
213
213
  scriptresult)
214
214
  // ✅ Force test failure if soft errors exist
215
- if (softErrors.length > 0) {
216
- throw combinedError; // 👈 this is what forces the test to fail in WDIO
217
- }
215
+ // if (softErrors.length > 0) {
216
+ // throw combinedError; // 👈 this is what forces the test to fail in WDIO
217
+ // }
218
218
 
219
219
  },
220
220
  /**
@@ -235,7 +235,7 @@ const commonconfig = {
235
235
  after: async function (result, config, capabilities, specs) {
236
236
  console.log('==== AFTER HOOK ====');
237
237
  console.log('====> All tests are completed.' + result);
238
- BUFFER.setItem("RESULT_DATA", global.__SOFT_FAIL__ ? 1 : result);
238
+ BUFFER.setItem("RESULT_DATA", result);
239
239
  console.log("====> Result data :" + BUFFER.getItem("RESULT_DATA"))
240
240
  /// const resultdetails = {}
241
241
  resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
@@ -303,10 +303,10 @@ const commonconfig = {
303
303
  console.log('Execution Time:', results.duration);
304
304
  console.log('Exit Code:', exitCode);
305
305
  console.log('==== ALL TESTS ARE COMPLETED ====');
306
- if (global.__SOFT_FAIL__) {
307
- console.log('❌ One or more tests failed due to soft assertion.');
308
- process.exit(1); // ✅ Force failure
309
- }
306
+ // if (global.__SOFT_FAIL__) {
307
+ // console.log('❌ One or more tests failed due to soft assertion.');
308
+ // process.exit(1); // ✅ Force failure
309
+ // }
310
310
 
311
311
  return exitCode;
312
312
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "4.0.35",
3
+ "version": "4.0.36",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",
@@ -39,6 +39,7 @@
39
39
  "chai": "^5.1.1",
40
40
  "crypto-js": "^4.2.0",
41
41
  "deepmerge": "^4.3.1",
42
+ "express": "^5.1.0",
42
43
  "form-data": "^4.0.0",
43
44
  "fs": "^0.0.1-security",
44
45
  "js-yaml": "^4.1.0",
@@ -0,0 +1,56 @@
1
+ const express = require('express');
2
+ const app = express();
3
+
4
+ // Middleware to parse JSON payloads
5
+ app.use(express.json());
6
+
7
+ // Define the webhook path (match the path used in smee or GitHub webhook)
8
+ app.post('/webhook', (request, response) => {
9
+ // Respond early so GitHub doesn't time out
10
+ response.status(202).send('Accepted');
11
+
12
+ // Get event type from header
13
+ const githubEvent = request.headers['x-github-event'];
14
+ console.log(`Received event: ${githubEvent}`);
15
+
16
+ const data = request.body;
17
+
18
+ // Handle specific GitHub events
19
+ if (githubEvent === 'issues') {
20
+ const action = data.action;
21
+ console.log(`Received action: ${action}`);
22
+
23
+ if (action === 'opened') {
24
+ console.log(`An issue was opened with this title: ${data.issue.title}`);
25
+ } else if (action === 'closed') {
26
+ console.log(`An issue was closed by ${data.issue.user.login}`);
27
+ } else {
28
+ console.log(`Unhandled action for the issue event: ${action}`);
29
+ }
30
+
31
+ } else if (githubEvent === 'ping') {
32
+ console.log('GitHub sent the ping event');
33
+
34
+ } else {
35
+ // For all other events
36
+ console.log(`Unhandled event: ${githubEvent}`);
37
+ console.log(`Payload: ${JSON.stringify(data, null, 2)}`);
38
+
39
+ if (data.action) {
40
+ console.log(`Received action: ${data.action}`);
41
+ }
42
+
43
+ if (data.workflow_run) {
44
+ console.log(`Workflow run ID: ${data.workflow_run.id}`);
45
+ console.log(`Workflow name: ${data.workflow_run.name}`);
46
+ console.log(`Status: ${data.workflow_run.status}`);
47
+ console.log(`Conclusion: ${data.workflow_run.conclusion}`);
48
+ }
49
+ }
50
+ });
51
+
52
+ // Start server on port 3000
53
+ const port = 3000;
54
+ app.listen(port, () => {
55
+ console.log(`Server is running on port ${port}`);
56
+ });