Skip to content

Commit 4e365a5

Browse files
Merge pull request #7 from akshatlambdatest/master
Added function to fetch enhanced cypress report.
2 parents 7b60a52 + 6e5f4cb commit 4e365a5

File tree

4 files changed

+107
-65
lines changed

4 files changed

+107
-65
lines changed

README.md

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
![LambdaTest Logo](https://www.lambdatest.com/static/images/logo.svg)
22

33
# Node LambdaTest
4+
45
[![npm version](https://badge.fury.io/js/%40lambdatest%2Fnode-rest-client.svg)](https://badge.fury.io/js/%40lambdatest%2Fnode-rest-client)
56

67
A Node.js JavaScript client for working with [LambdaTest](https://www.lambdatest.com) through [Automation API](https://www.lambdatest.com/support/docs/api-doc).
@@ -16,19 +17,17 @@ npm i @lambdatest/node-rest-client
1617
```js
1718
var lambdaRestClient = require("@lambdatest/node-rest-client");
1819
var lambdaCredentials = {
19-
username: process.env.LT_USERNAME || "<Your username>",
20-
accessKey: process.env.LT_ACCESS_KEY || "<Your access key>"
20+
username: process.env.LT_USERNAME || "<Your username>",
21+
accessKey: process.env.LT_ACCESS_KEY || "<Your access key>",
2122
};
2223

2324
// Automation APIs
24-
var lambdaAutomationClient = lambdaRestClient.AutomationClient(
25-
lambdaCredentials
26-
);
27-
28-
lambdaAutomationClient.fetchBuilds(function(error, builds) {
29-
if (!error) {
30-
console.log(builds);
31-
}
25+
var lambdaAutomationClient = lambdaRestClient.AutomationClient(lambdaCredentials);
26+
27+
lambdaAutomationClient.fetchBuilds(function (error, builds) {
28+
if (!error) {
29+
console.log(builds);
30+
}
3231
});
3332
```
3433

@@ -40,10 +39,10 @@ lambdaAutomationClient.fetchBuilds(function(error, builds) {
4039

4140
Creates a new automation client instance.
4241

43-
- `lambdaCredentials`: credentials for all requests.
44-
- `username`: The username for the LambdaTest account.
45-
- `accessKey`: The accessKey for the LambdaTest account.
46-
- `logFile`: You can provide a specific path to log file.If you won't provide a path then the logs would be saved in your present working directory by the filename: lambda_api.log
42+
- `lambdaCredentials`: credentials for all requests.
43+
- `username`: The username for the LambdaTest account.
44+
- `accessKey`: The accessKey for the LambdaTest account.
45+
- `logFile`: You can provide a specific path to log file.If you won't provide a path then the logs would be saved in your present working directory by the filename: lambda_api.log
4746

4847
Build Object
4948
This object is dedicated to help you perform any operation on your test builds.
@@ -52,14 +51,14 @@ This object is dedicated to help you perform any operation on your test builds.
5251

5352
Fetch all the details regarding test builds.
5453

55-
- (optional) `params`: Parameters(offset, limit, status, fromdate, todate, sort)
56-
- `offset` - used to limit the number of lists. For example: offset=10
57-
- `limit` - used to limit the number of records. For example: limit=10
58-
- `status` - used to extract the status for list of builds in comma separated format. For example: "running,queued,completed,timeout and error"
59-
- `fromdate` - to fetch all the builds executed past a particular date in the (YYYY-MM-DD) date format.
60-
- `todate` - to fetch all the builds executed till a particular date in the (YYYY-MM-DD) date format.
61-
- `sort` - to sort the list in ascending or descending order using multiple keys. For example: "asc.user_id,desc.org_id"
62-
- `callback` (`function(error, builds)`): A callback to invoke when the API call is complete.
54+
- (optional) `params`: Parameters(offset, limit, status, fromdate, todate, sort)
55+
- `offset` - used to limit the number of lists. For example: offset=10
56+
- `limit` - used to limit the number of records. For example: limit=10
57+
- `status` - used to extract the status for list of builds in comma separated format. For example: "running,queued,completed,timeout and error"
58+
- `fromdate` - to fetch all the builds executed past a particular date in the (YYYY-MM-DD) date format.
59+
- `todate` - to fetch all the builds executed till a particular date in the (YYYY-MM-DD) date format.
60+
- `sort` - to sort the list in ascending or descending order using multiple keys. For example: "asc.user_id,desc.org_id"
61+
- `callback` (`function(error, builds)`): A callback to invoke when the API call is complete.
6362

6463
#### lambdaAutomationClient.fetchBuildById(buildId, callback)
6564

@@ -69,24 +68,24 @@ Fetch all the details of a particular test build by ID. Details would include:
6968
2. Number of tests executed
7069
3. User who executed the build
7170

72-
- `buildId` - a unique ID for the build type you wish to fetch.
73-
- `callback` (`function(error, build)`) - A callback to invoke when the API call is complete.
71+
- `buildId` - a unique ID for the build type you wish to fetch.
72+
- `callback` (`function(error, build)`) - A callback to invoke when the API call is complete.
7473

7574
#### lambdaAutomationClient.deleteBuildById(buildId, callback)
7675

7776
To delete a particular build from your automation dashboard.
7877

79-
- `buildId` - ID of the particular build you wish to delete.
80-
- `callback` (`function(error, build)`): A callback to invoke when the API call is complete.
78+
- `buildId` - ID of the particular build you wish to delete.
79+
- `callback` (`function(error, build)`): A callback to invoke when the API call is complete.
8180

8281
#### lambdaAutomationClient.updateBuildById(buildId, requestBody, callback)
8382

8483
To rename a test build.
8584

86-
- `buildId` - ID of the particular build you wish to rename.
87-
- `requestBody` - Object(name).
88-
- `name`- Changed name
89-
- `callback` (`function(error, build)`) - A callback to invoke when the API call is complete.
85+
- `buildId` - ID of the particular build you wish to rename.
86+
- `requestBody` - Object(name).
87+
- `name`- Changed name
88+
- `callback` (`function(error, build)`) - A callback to invoke when the API call is complete.
9089

9190
Session Object
9291
This object is dedicated to help you perform any operation related to your test sessions.
@@ -95,16 +94,16 @@ This object is dedicated to help you perform any operation related to your test
9594

9695
Fetch all the details regarding test sessions.
9796

98-
- (optional) `params`: Parameters(build_id, username, offset, limit, status, fromdate, todate, sort)
99-
- `build_id` - to filter sessions executed in a particular build.
100-
- `username` - to filter sessions executed by a particular user.
101-
- `offset` - used to limit the number of lists. For example: offset=10
102-
- `limit` - used to limit the number of records. For example: limit=10
103-
- `status` - used to extract the status for list of builds in comma separated format. For example: "running,queued,completed,timeout and error"
104-
- `fromdate` - to fetch all the builds executed past a particular date in the (YYYY-MM-DD) date format.
105-
- `todate` - to fetch all the builds executed till a particular date in the (YYYY-MM-DD) date format.
106-
- `sort` - to sort the list in ascending or descending order using multiple keys. For example: "asc.user_id,desc.org_id"
107-
- `callback` (`function(error, sessions)`): A callback to invoke when the API call is complete.
97+
- (optional) `params`: Parameters(build_id, username, offset, limit, status, fromdate, todate, sort)
98+
- `build_id` - to filter sessions executed in a particular build.
99+
- `username` - to filter sessions executed by a particular user.
100+
- `offset` - used to limit the number of lists. For example: offset=10
101+
- `limit` - used to limit the number of records. For example: limit=10
102+
- `status` - used to extract the status for list of builds in comma separated format. For example: "running,queued,completed,timeout and error"
103+
- `fromdate` - to fetch all the builds executed past a particular date in the (YYYY-MM-DD) date format.
104+
- `todate` - to fetch all the builds executed till a particular date in the (YYYY-MM-DD) date format.
105+
- `sort` - to sort the list in ascending or descending order using multiple keys. For example: "asc.user_id,desc.org_id"
106+
- `callback` (`function(error, sessions)`): A callback to invoke when the API call is complete.
108107

109108
#### lambdaAutomationClient.fetchSessionById(sessionId, callback)
110109

@@ -117,61 +116,61 @@ Fetch all the details of a particular test session by ID. Details that are fetch
117116
5. Browser version
118117
6. All generated logs endpoint
119118

120-
- `sessionId` - a unique ID for the build type you wish to fetch.
121-
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
119+
- `sessionId` - a unique ID for the build type you wish to fetch.
120+
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
122121

123122
#### lambdaAutomationClient.deleteSessionById(sessionId, callback)
124123

125124
To delete a particular session from your automation dashboard.
126125

127-
- `sessionId` - ID of the particular session you wish to delete.
128-
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
126+
- `sessionId` - ID of the particular session you wish to delete.
127+
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
129128

130129
#### lambdaAutomationClient.updateSessionById(sessionId, requestBody, callback)
131130

132131
To rename a test session or to update a test session as "passed" or "failed".
133132

134-
- `sessionId` - ID of the particular session you wish to rename.
135-
- `requestBody` - Object(name, status_ind).
136-
- `name`- Changed name
137-
- `status_ind`- Updated status(passed/failed)
138-
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
133+
- `sessionId` - ID of the particular session you wish to rename.
134+
- `requestBody` - Object(name, status_ind).
135+
- `name`- Changed name
136+
- `status_ind`- Updated status(passed/failed)
137+
- `callback` (`function(error, session)`): A callback to invoke when the API call is complete.
139138

140139
#### lambdaAutomationClient.fetchSessionScreenshot(sessionId, callback)
141140

142141
To extract step-by-step screenshot of a particular test session. The screenshots would be fetched in the zip format.
143142

144-
- `sessionId` - ID of the particular session for which you wish to fetch step-by-step screenshots.
145-
- `callback` (`function(error, screenshots)`): A callback to invoke when the API call is complete.
143+
- `sessionId` - ID of the particular session for which you wish to fetch step-by-step screenshots.
144+
- `callback` (`function(error, screenshots)`): A callback to invoke when the API call is complete.
146145

147146
#### lambdaAutomationClient.fetchSessionVideo(sessionId, callback)
148147

149148
To fetch a recorded video of your test session.
150149

151-
- `sessionId` - ID of the particular session for which you wish to fetch the recorded video.
152-
- `callback` (`function(error, video)`): A callback to invoke when the API call is complete.
150+
- `sessionId` - ID of the particular session for which you wish to fetch the recorded video.
151+
- `callback` (`function(error, video)`): A callback to invoke when the API call is complete.
153152

154153
#### lambdaAutomationClient.fetchSessionCommandLogs(sessionId, callback)
155154

156155
To fetch the entire command logs of a test session in plain JSON text.
157156

158-
- `sessionId` - ID of the particular session for which you wish to fetch the command logs.
159-
- `callback` (`function(error, commandLogs)`): A callback to invoke when the API call is complete.
157+
- `sessionId` - ID of the particular session for which you wish to fetch the command logs.
158+
- `callback` (`function(error, commandLogs)`): A callback to invoke when the API call is complete.
160159

161160
#### lambdaAutomationClient.fetchSessionNetworkLogs(sessionId, callback)
162161

163162
To fetch every response and request recieved by the Selenium Grid for a particular test session in plain JSON text.
164163

165-
- `sessionId` - ID of the particular session for which you wish to fetch the Selenium logs.
166-
- `callback` (`function(error, networkLogs)`): A callback to invoke when the API call is complete.
164+
- `sessionId` - ID of the particular session for which you wish to fetch the Selenium logs.
165+
- `callback` (`function(error, networkLogs)`): A callback to invoke when the API call is complete.
167166

168167
#### lambdaAutomationClient.fetchSessionConsoleLogs(sessionId, callback)
169168

170169
To fetch all of the console errors thrown throughout interation between web-application and Selenium script for a particular test session in plain JSON text.
171170
To fetch all of the console errors for a particular test session in plain JSON text.
172171

173-
- `sessionId` - ID of the particular session for which you wish to fetch the console logs.
174-
- `callback` (`function(error, consoleLogs)`): A callback to invoke when the API call is complete.
172+
- `sessionId` - ID of the particular session for which you wish to fetch the console logs.
173+
- `callback` (`function(error, consoleLogs)`): A callback to invoke when the API call is complete.
175174

176175
Tunnel Object
177176
This object is dedicated to represent information regarding the Lambda Tunnel for performing automated cross browser testing of your locally hosted web-apps.
@@ -180,22 +179,29 @@ This object is dedicated to represent information regarding the Lambda Tunnel fo
180179

181180
To fetch the entire list of active tunnels in your account.
182181

183-
- `callback` (`function(error, tunnels)`): A callback to invoke when the API call is complete.
182+
- `callback` (`function(error, tunnels)`): A callback to invoke when the API call is complete.
184183

185184
#### lambdaAutomationClient.deleteTunnelById(tunnelId, callback)
186185

187186
To delete a particular Lambda Tunnel running in your account.
188187

189-
- `tunnelId` - ID of the particular Tunnel for which you wish to delete.
190-
- `callback` (`function(error, tunnel)`): A callback to invoke when the API call is complete.
188+
- `tunnelId` - ID of the particular Tunnel for which you wish to delete.
189+
- `callback` (`function(error, tunnel)`): A callback to invoke when the API call is complete.
191190

192191
Platform Object
193192

194193
#### lambdaAutomationClient.fetchPlatforms(callback)
195194

196195
To fetch syntax for every browser and browser version offered by LambdaTest.
197196

198-
- `callback` (`function(error, platforms)`): A callback to invoke when the API call is complete.
197+
- `callback` (`function(error, platforms)`): A callback to invoke when the API call is complete.
198+
199+
#### lambdaAutomationClient.fetchCyEnhancedReport(testID, callback)
200+
201+
To fetch enhanced cypress report.
202+
203+
- `testID` - Test ID of the particular test whose detailed report is to be fetched.
204+
- `callback` (`function(error, report)`): A callback to invoke when the API call is complete.
199205

200206
## About LambdaTest
201207

lib/automation_client.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,42 @@ AutomationApiClient.prototype.getSessionsOfBuild = async function (params) {
662662
};
663663
}
664664
};
665+
/**
666+
* Add this method by Extending ApiClient for fetching enhanced cypress test report.
667+
* @param {string} testID Test ID whose report is to be found
668+
* @param {Function} fnCallback is callback function.
669+
* @return {!<Array>ConsoleLog|Error} return Console Logs or Error.
670+
*/
671+
AutomationApiClient.prototype.fetchCyEnhancedReport = function (testID, fnCallback) {
672+
if (typeof testID === "function" || typeof testID === "object") {
673+
throw new Error("testID is Required");
674+
}
675+
if (typeof fnCallback === "function") {
676+
ApiClient.request(
677+
{
678+
url: "/cypress/mochawesome/enhanced/" + testID,
679+
method: "GET",
680+
},
681+
fnCallback
682+
);
683+
} else {
684+
return new Promise((resolve, reject) => {
685+
ApiClient.request(
686+
{
687+
url: "/cypress/mochawesome/enhanced/" + testID,
688+
method: "GET",
689+
},
690+
function (err, response) {
691+
if (err) {
692+
reject(err);
693+
} else {
694+
resolve(response);
695+
}
696+
}
697+
);
698+
});
699+
}
700+
};
665701

666702
module.exports = {
667703
AutomationClient: function (settings) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/node-rest-client",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "LambdaTest Rest Client for Node.js",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)