froth-webdriverio-framework 3.0.22 → 3.0.24
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.
- package/config/commonconfig.js +46 -47
- package/package.json +1 -1
package/config/commonconfig.js
CHANGED
|
@@ -4,6 +4,7 @@ global.BUFFER = new LocalStorage('./storage');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const exeDetails = require("../api/getexecutionDetails")
|
|
6
6
|
const getBSSessionDetails = require("../api/browsersatckSessionInfo");
|
|
7
|
+
const { fail } = require("assert");
|
|
7
8
|
const isBrowserStackEnabled = process.env.BROWSERSTACK;
|
|
8
9
|
let starttime;
|
|
9
10
|
let endtime;
|
|
@@ -31,10 +32,12 @@ const commonconfig = {
|
|
|
31
32
|
*/
|
|
32
33
|
beforeSuite: async function (suite) {
|
|
33
34
|
try {
|
|
34
|
-
console.log(
|
|
35
|
+
console.log(`========= Test suite: ' ${suite.title}' has been started=========`,);
|
|
36
|
+
const specCount = suite.tests.length;
|
|
37
|
+
console.log(`========= Number of specs in the suite: ${specCount}`);
|
|
38
|
+
|
|
35
39
|
starttime = new Date().getTime();
|
|
36
|
-
|
|
37
|
-
// BUFFER.setItem("SESSION_ID", sessionId)
|
|
40
|
+
|
|
38
41
|
if (isBrowserStackEnabled === true) {
|
|
39
42
|
console.log("BrowserStack is enabled");
|
|
40
43
|
await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY);
|
|
@@ -53,16 +56,12 @@ const commonconfig = {
|
|
|
53
56
|
* @param {object} context scope object the test was executed with
|
|
54
57
|
*/
|
|
55
58
|
beforeTest: function (test, context) {
|
|
56
|
-
console.log(
|
|
59
|
+
console.log(`========= Test '${test.title}' Started ========= `);
|
|
60
|
+
|
|
57
61
|
// console.log("File Name:", test.file);
|
|
58
62
|
|
|
59
63
|
},
|
|
60
64
|
|
|
61
|
-
afterStep: function (test, context, { error, result, duration, passed, retries }) {
|
|
62
|
-
// if (passed) {
|
|
63
|
-
// browser.takeScreenshot();
|
|
64
|
-
// }
|
|
65
|
-
},
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
67
|
* Function to be executed after a test (in Mocha/Jasmine only)
|
|
@@ -75,28 +74,33 @@ const commonconfig = {
|
|
|
75
74
|
* @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }`
|
|
76
75
|
*/
|
|
77
76
|
afterTest: async function (test, context, { error, result, duration, passed, retries }) {
|
|
78
|
-
console.log(
|
|
77
|
+
console.log(`========= Test name '${test.title}' finished.========`);
|
|
79
78
|
|
|
80
79
|
const fileName = path.basename(test.file);
|
|
81
|
-
console.log('Test File Name:', fileName);
|
|
80
|
+
console.log('========= Test File Name:', fileName);
|
|
82
81
|
// BUFFER.setItem("FROTH_TOTAL_DURATION", Number(BUFFER.getItem("FROTH_TOTAL_DURATION")) + duration)
|
|
83
|
-
console.log(
|
|
84
|
-
console.log(
|
|
82
|
+
console.log(`========= Total Duration for this test: ${duration}ms`);
|
|
83
|
+
console.log(`========= Status of test: ${passed}`);
|
|
85
84
|
let scriptresult = "NOT RUN";
|
|
86
|
-
let scriptid = BUFFER.getItem(fileName.replace(".js", ""))
|
|
87
85
|
|
|
88
86
|
if (passed) {
|
|
89
87
|
scriptresult = "PASSED"
|
|
88
|
+
passedTests++;
|
|
90
89
|
}
|
|
91
90
|
else {
|
|
92
91
|
scriptresult = "FAILED"
|
|
92
|
+
failedTests++;
|
|
93
93
|
}
|
|
94
94
|
if (error) {
|
|
95
|
-
console.error(
|
|
96
|
-
scriptresult = "FAILED"
|
|
95
|
+
console.error(`========= Error occured while executing the test: ${error.message}`);
|
|
96
|
+
// scriptresult = "FAILED"
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
await exeDetails.updateScriptExecutionStatus(
|
|
98
|
+
let scriptid = BUFFER.getItem(fileName.replace(".js", ""))
|
|
99
|
+
await exeDetails.updateScriptExecutionStatus(
|
|
100
|
+
BUFFER.getItem("ORGANISATION_DOMAIN_URL"),
|
|
101
|
+
BUFFER.getItem("FROTH_LOGIN_TOKEN"),
|
|
102
|
+
scriptid,
|
|
103
|
+
scriptresult)
|
|
100
104
|
|
|
101
105
|
},
|
|
102
106
|
/**
|
|
@@ -104,7 +108,7 @@ const commonconfig = {
|
|
|
104
108
|
* @param {object} suite suite details
|
|
105
109
|
*/
|
|
106
110
|
afterSuite: function (suite) {
|
|
107
|
-
console.log(
|
|
111
|
+
console.log(`========= Test suite '${suite.title}' has completed.`);
|
|
108
112
|
},
|
|
109
113
|
/**
|
|
110
114
|
* Gets executed after all tests are done. You still have access to all global variables from
|
|
@@ -114,45 +118,36 @@ const commonconfig = {
|
|
|
114
118
|
* @param {Array.<String>} specs List of spec file paths that ran
|
|
115
119
|
*/
|
|
116
120
|
after: async function (result, config, capabilities, specs) {
|
|
117
|
-
console.log('All tests are
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// const totalDefinedTests = exports.config.specs.length; // Total test files/specs defined
|
|
121
|
-
const executedTests = result.finished; // Tests that were executed
|
|
122
|
-
const passedTests = result.passed;
|
|
123
|
-
const failedTests = result.failed;
|
|
124
|
-
//const notRunTests = totalDefinedTests - executedTests;
|
|
125
|
-
|
|
126
|
-
// console.log(`Total Defined Tests: ${totalDefinedTests}`);
|
|
127
|
-
console.log(`Executed Tests: ${executedTests}`);
|
|
128
|
-
console.log(`Passed Tests: ${passedTests}`);
|
|
129
|
-
console.log(`Failed Tests: ${failedTests}`);
|
|
130
|
-
// console.log(`Tests Not Run: ${notRunTests}`);
|
|
121
|
+
console.log('========= All tests are completed.' + result);
|
|
131
122
|
|
|
132
123
|
BUFFER.setItem("RESULT_DATA", result);
|
|
133
|
-
console.log("
|
|
124
|
+
console.log("========= Result data :" + BUFFER.getItem("RESULT_DATA"))
|
|
125
|
+
|
|
134
126
|
const resultdetails = {}
|
|
135
127
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
136
|
-
console.log("Total Duration:" + BUFFER.getItem("FROTH_TOTAL_DURATION"));
|
|
137
|
-
console.log("
|
|
128
|
+
console.log("========= Total Duration taken for the suite:" + BUFFER.getItem("FROTH_TOTAL_DURATION"));
|
|
129
|
+
console.log("========= Execution Status from results" + resultdetails.excution_status);
|
|
130
|
+
|
|
138
131
|
resultdetails.excution_time = await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"))
|
|
139
132
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
140
133
|
|
|
141
134
|
},
|
|
142
135
|
|
|
143
136
|
afterSession: async function (config, capabilities, specs) {
|
|
144
|
-
console.log('This is the aftersession hook');
|
|
137
|
+
console.log('========= This is the aftersession hook');
|
|
145
138
|
// Perform any cleanup or post-test actions here
|
|
146
139
|
|
|
147
140
|
endtime = new Date().getTime();
|
|
148
141
|
let totalDuration = endtime - starttime;
|
|
149
|
-
console.log("Total Duration:" + totalDuration);
|
|
142
|
+
console.log("========= Total Duration in after session based on start time and end time:" + totalDuration);
|
|
143
|
+
|
|
150
144
|
if (isBrowserStackEnabled)
|
|
151
145
|
await getBSSessionDetails(process.env.BS_SESSION_TYPE, process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY);
|
|
152
146
|
|
|
153
147
|
const resultdetails = {}
|
|
154
148
|
resultdetails.excution_status = BUFFER.getItem("RESULT_DATA") == 0 ? 'PASSED' : 'FAILED'
|
|
155
|
-
console.log("Total Duration:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION")));
|
|
149
|
+
console.log("========= Total Duration calculation:" + BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION")));
|
|
150
|
+
|
|
156
151
|
resultdetails.excution_time = BUFFER.getItem("FROTH_TOTAL_DURATION") === 0 ? await convertTimetoHHMMSS(totalDuration) : await secondsToTime(BUFFER.getItem("FROTH_TOTAL_DURATION"))
|
|
157
152
|
await exeDetails.updateExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"), resultdetails)
|
|
158
153
|
BUFFER.clear();
|
|
@@ -160,16 +155,20 @@ const commonconfig = {
|
|
|
160
155
|
},
|
|
161
156
|
|
|
162
157
|
onComplete: async function (exitCode, config, capabilities, results) {
|
|
163
|
-
console.log('This is the onComplete hook');
|
|
164
|
-
// Perform any cleanup or post-test actions here
|
|
165
|
-
const { finished, specs, passed, failed } = results;
|
|
166
|
-
|
|
158
|
+
console.log('========= This is the onComplete hook', results);
|
|
167
159
|
console.log('--- Test Results Summary ---');
|
|
168
|
-
console.log(`Total Spec Files: ${specs.length}`);
|
|
169
|
-
console.log(`Passed: ${passed}`);
|
|
170
|
-
console.log(`Failed: ${failed}`);
|
|
171
|
-
console.log(`Total Time: ${Math.round(finished / 1000)} seconds`);
|
|
172
160
|
console.log('----------------------------');
|
|
161
|
+
console.log('Total Tests:', results.total);
|
|
162
|
+
console.log('Passed:', results.passed);
|
|
163
|
+
console.log('Failed:', results.failed);
|
|
164
|
+
console.log('Skipped:', results.skipped);
|
|
165
|
+
console.log('----------------------------');
|
|
166
|
+
console.log('Execution Time:', results.duration);
|
|
167
|
+
console.log('----------------------------');
|
|
168
|
+
console.log('Exit Code:', exitCode);
|
|
169
|
+
console.log('----------------------------');
|
|
170
|
+
console.log('========= All tests are done, exiting the browser session.');
|
|
171
|
+
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
};
|