Repository: nightwatchjs/nightwatch
Pull request #3240 (2022-06-15 08:08:07)

Minor jsdoc updates in CDP commands.
Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.

- [ ] Create a new branch from master (e.g. `features/my-new-feature` or `issue/123-my-bugfix`);
- [ ] If you're fixing a bug also create an issue if one doesn't exist yet;
- [ ] If it's a new feature explain why do you think it's necessary. Please check with the maintainers beforehand to make sure it is something that we will accept. Usually we only accept new features if we feel that they will benefit the entire community;
- [ ] Please avoid sending PRs which contain drastic or low level changes. If you are certain that the changes are needed, please discuss them beforehand and indicate what the impact will be;
- [ ] If your change is based on existing functionality please consider refactoring first. Pull requests that duplicate code will most likely be ignored;
- [ ] Do not include changes that are not related to the issue at hand;
- [ ] Follow the same coding style with regards to spaces, semicolons, variable naming etc.;
- [ ] Always add unit tests - PRs without tests are most of the times ignored.



Patch:
diff --git a/lib/api/client-commands/captureBrowserExceptions.js b/lib/api/client-commands/captureBrowserExceptions.js
index 18458a5c..648718c3 100644
--- a/lib/api/client-commands/captureBrowserExceptions.js
+++ b/lib/api/client-commands/captureBrowserExceptions.js
@@ -25,7 +25,9 @@ const {Logger} = require('../../utils');
  * @method captureBrowserExceptions
  * @syntax .captureBrowserExceptions(callback)
  * @param {function} callback Callback function to be called when a new exception has taken place.
- * @api protocol.sessions
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @moreinfo nightwatchjs.org/guide/running-tests/catch-js-exceptions.html
  */
 class CatchJsExceptions extends ClientCommand {
 
diff --git a/lib/api/client-commands/captureNetworkRequests.js b/lib/api/client-commands/captureNetworkRequests.js
index 7b5d91d3..154a53c8 100644
--- a/lib/api/client-commands/captureNetworkRequests.js
+++ b/lib/api/client-commands/captureNetworkRequests.js
@@ -20,14 +20,16 @@ const {Logger} = require('../../utils');
  * @method captureNetworkRequests
  * @syntax .captureNetworkRequests(callback)
  * @param {function} callback callback function to be called whenever a outgoing network call is made.
- * @api protocol.userprompts
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @moreinfo nightwatchjs.org/guide/network-requests/capture-network-calls.html
  */
 class CaptureNetworkCalls extends ClientCommand {
 
   performAction(callback) {
 
     if (!this.api.isChrome() && !this.api.isEdge()) {
-      const error = new Error('The command captureNetworkRequests() is only supported in Chrome and Edge drivers');
+      const error = new Error('The command .captureNetworkRequests() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
@@ -35,7 +37,7 @@ class CaptureNetworkCalls extends ClientCommand {
 
     const userCallback = this.userCallback;
     if (userCallback === undefined) {
-      const error =  new Error('Callback is missing from .captureNetworkRequests command.');
+      const error =  new Error('Callback is missing from .captureNetworkRequests() command.');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/enablePerformanceMetrics.js b/lib/api/client-commands/enablePerformanceMetrics.js
index c59da2c7..45b28bc0 100644
--- a/lib/api/client-commands/enablePerformanceMetrics.js
+++ b/lib/api/client-commands/enablePerformanceMetrics.js
@@ -20,7 +20,6 @@ const {Logger} = require('../../utils');
  * @param {function} [callback] Optional callback function to be called when the command finishes.
  * @api protocol.cdp
  * @since 2.2.0
- * @see https://chromedevtools.github.io/devtools-protocol/tot/Performance/
  * @moreinfo www.selenium.dev/documentation/webdriver/bidirectional/chrome_devtools/#collect-performance-metrics
  */
 class EnablePerformanceMetrics extends ClientCommand {
@@ -28,7 +27,7 @@ class EnablePerformanceMetrics extends ClientCommand {
   performAction(callback) {
 
     if (!this.api.isChrome() && !this.api.isEdge()) {
-      const error = new Error('.enablePerformanceMetrics() is only supported in Chrome and Edge drivers');
+      const error = new Error('The command .enablePerformanceMetrics() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/getPerformanceMetrics.js b/lib/api/client-commands/getPerformanceMetrics.js
index b8898898..3e24b92e 100644
--- a/lib/api/client-commands/getPerformanceMetrics.js
+++ b/lib/api/client-commands/getPerformanceMetrics.js
@@ -17,15 +17,16 @@ const {Logger} = require('../../utils');
  * @method getPerformanceMetrics
  * @syntax .getPerformanceMetrics(callback)
  * @param {function} callback Callback function which is called with the performance metrics as argument.
- * @api protocol.userprompts
- * @returns {object} Performance metrics 
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @returns {object} Performance metrics
  */
 class GetPerformanceMetrics extends ClientCommand {
 
   performAction(callback) {
 
     if (!this.api.isChrome()  && !this.api.isEdge()) {
-      const error =  new Error('GetPerformanceMetrics is only supported in Chrome and Edge drivers');
+      const error =  new Error('The command .getPerformanceMetrics() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/mockNetworkResponse.js b/lib/api/client-commands/mockNetworkResponse.js
index b492535e..88c6055f 100644
--- a/lib/api/client-commands/mockNetworkResponse.js
+++ b/lib/api/client-commands/mockNetworkResponse.js
@@ -22,14 +22,16 @@ const {Logger} = require('../../utils');
  * @param {string} urlToIntercept URL to intercept and mock the response from
  * @param {object} response Response to return
  * @param {function} [callback] Optional callback function to be called when the command finishes.
- * @api protocol.userprompts
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @moreinfo nightwatchjs.org/guide/network-requests/mock-network-response.html
  */
 class MockNetworkResponse extends ClientCommand {
 
   performAction(callback) {
 
     if (!this.api.isChrome()  && !this.api.isEdge()) {
-      const error =  new Error('MockNetworkResponse is only supported in Chrome and Edge drivers');
+      const error =  new Error('The command .mockNetworkResponse() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/setDeviceDimensions.js b/lib/api/client-commands/setDeviceDimensions.js
index 6590494b..8bfffd57 100644
--- a/lib/api/client-commands/setDeviceDimensions.js
+++ b/lib/api/client-commands/setDeviceDimensions.js
@@ -20,14 +20,16 @@ const {Logger} = require('../../utils');
  * @syntax .setDeviceDimensions({width, height, deviceScaleFactor, mobile}, [callback])
  * @param {object} metrics
  * @param {function} [callback] Optional callback function to be called when the command finishes.
- * @api protocol.mobile
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @moreinfo nightwatchjs.org/guide/mobile-web-testing/override-device-dimensions.html
  */
 class SetDeviceDimensions extends ClientCommand {
 
   performAction(callback) {
 
     if (!this.api.isChrome()  && !this.api.isEdge()) {
-      const error =  new Error('SetDeviceDimensions is only supported in Chrome and Edge drivers');
+      const error =  new Error('The command .setDeviceDimensions() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/setGeolocation.js b/lib/api/client-commands/setGeolocation.js
index d506e40e..b51701e5 100644
--- a/lib/api/client-commands/setGeolocation.js
+++ b/lib/api/client-commands/setGeolocation.js
@@ -21,14 +21,16 @@ const {Logger} = require('../../utils');
  * @syntax .setGeolocation({latitude, longitude, accuracy}, [callback])
  * @param {object} coordinates
  * @param {function} [callback] Optional callback function to be called when the command finishes.
- * @api protocol.userprompts
+ * @api protocol.cdp
+ * @since 2.2.0
+ * @moreinfo nightwatchjs.org/guide/network-requests/mock-geolocation.html
  */
 class SetGeolocation extends ClientCommand {
 
   performAction(callback) {
 
     if (!this.api.isChrome()  && !this.api.isEdge()) {
-      const error =  new Error('SetGeolocation is only supported in Chrome and Edge drivers');
+      const error =  new Error('The command .setGeolocation() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);
diff --git a/lib/api/client-commands/takeHeapSnapshot.js b/lib/api/client-commands/takeHeapSnapshot.js
index 79ca4324..b4a9fc2b 100644
--- a/lib/api/client-commands/takeHeapSnapshot.js
+++ b/lib/api/client-commands/takeHeapSnapshot.js
@@ -2,8 +2,8 @@ const ClientCommand = require('./_base-command.js');
 const {Logger} = require('../../utils');
 
 /**
- * Takes a heap snapshot and saves it in JSON format serialized to string.
- * Load the snapshot file into Chrome DevTools memory tab to inspect.
+ * Takes a heap snapshot and saves it in string-serialized JSON format.
+ * Load the snapshot file into Chrome DevTools' Memory tab to inspect.
  *
  * @example
  *  this.demoTest = function (browser) {
@@ -16,7 +16,8 @@ const {Logger} = require('../../utils');
  * @syntax .takeHeapSnapshot([heapSnapshotLocation], [callback])
  * @param {string} [heapSnapshotLocation] Optional Location where you want to save the generated heap snapshot file.
  * @param {function} [callback] Optional callback function which is called with the heap snapshot serialized to string as argument.
- * @api protocol.userprompts
+ * @api protocol.cdp
+ * @since 2.2.0
  * @returns {string} Heap snapshot serialized into string.
  */
 class TakeHeapSnapshot extends ClientCommand {
@@ -24,7 +25,7 @@ class TakeHeapSnapshot extends ClientCommand {
   performAction(callback) {
 
     if (!this.api.isChrome()  && !this.api.isEdge()) {
-      const error =  new Error('TakeHeapSnapshot is only supported in Chrome and Edge drivers');
+      const error =  new Error('The command .takeHeapSnapshot() is only supported in Chrome and Edge drivers');
       Logger.error(error);
 
       return callback(error);


Test patch:
diff --git a/test/src/api/commands/client/testCaptureNetworkRequests.js b/test/src/api/commands/client/testCaptureNetworkRequests.js
index a25f03d3..57c83755 100644
--- a/test/src/api/commands/client/testCaptureNetworkRequests.js
+++ b/test/src/api/commands/client/testCaptureNetworkRequests.js
@@ -111,7 +111,7 @@ describe('.captureNetworkRequests()', function () {
     }).then(client => {
       client.api.captureNetworkRequests(undefined, function (result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'Callback is missing from .captureNetworkRequests command.');
+        assert.strictEqual(result.error, 'Callback is missing from .captureNetworkRequests() command.');
       });
 
       client.start(done);
@@ -130,7 +130,7 @@ describe('.captureNetworkRequests()', function () {
       const userCallback = (requestParams) => {console.log(requestParams)}
       client.api.captureNetworkRequests(userCallback, function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'The command captureNetworkRequests() is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .captureNetworkRequests() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testEnablePerformanceMetrics.js b/test/src/api/commands/client/testEnablePerformanceMetrics.js
index f3d9ecc7..12799a79 100644
--- a/test/src/api/commands/client/testEnablePerformanceMetrics.js
+++ b/test/src/api/commands/client/testEnablePerformanceMetrics.js
@@ -98,7 +98,7 @@ describe('.enablePerformanceMetrics()', function () {
     }).then(client => {
       client.api.enablePerformanceMetrics(true, function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, '.enablePerformanceMetrics() is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .enablePerformanceMetrics() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testGetPerformanceMetrics.js b/test/src/api/commands/client/testGetPerformanceMetrics.js
index 8d28f8b6..e41689f8 100644
--- a/test/src/api/commands/client/testGetPerformanceMetrics.js
+++ b/test/src/api/commands/client/testGetPerformanceMetrics.js
@@ -78,7 +78,7 @@ describe('.getPerformanceMetrics()', function () {
     }).then(client => {
       client.api.getPerformanceMetrics(function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'GetPerformanceMetrics is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .getPerformanceMetrics() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testMockNetworkResponse.js b/test/src/api/commands/client/testMockNetworkResponse.js
index 55021b94..80c7e87b 100644
--- a/test/src/api/commands/client/testMockNetworkResponse.js
+++ b/test/src/api/commands/client/testMockNetworkResponse.js
@@ -340,7 +340,7 @@ describe('.mockNetworkResponse()', function () {
       };
       client.api.mockNetworkResponse('https://www.google.com', response, function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'MockNetworkResponse is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .mockNetworkResponse() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testSetDeviceDimensions.js b/test/src/api/commands/client/testSetDeviceDimensions.js
index 5b2eaa92..eef62327 100644
--- a/test/src/api/commands/client/testSetDeviceDimensions.js
+++ b/test/src/api/commands/client/testSetDeviceDimensions.js
@@ -176,7 +176,7 @@ describe('.setDeviceDimensions()', function () {
     }).then(client => {
       client.api.setDeviceDimensions({width: 400, height: 600, deviceScaleFactor: 50}, function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'SetDeviceDimensions is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .setDeviceDimensions() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testSetGeolocation.js b/test/src/api/commands/client/testSetGeolocation.js
index a4e833d1..f164c9d8 100644
--- a/test/src/api/commands/client/testSetGeolocation.js
+++ b/test/src/api/commands/client/testSetGeolocation.js
@@ -210,7 +210,7 @@ describe('.setGeolocation()', function () {
     }).then(client => {
       client.api.setGeolocation({latitude: 35.689487, longitude: 139.691706, accuracy: 55}, function(result){
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'SetGeolocation is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .setGeolocation() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });
diff --git a/test/src/api/commands/client/testTakeHeapSnapshot.js b/test/src/api/commands/client/testTakeHeapSnapshot.js
index 60c0ab76..850f6b2a 100644
--- a/test/src/api/commands/client/testTakeHeapSnapshot.js
+++ b/test/src/api/commands/client/testTakeHeapSnapshot.js
@@ -165,7 +165,7 @@ describe('.takeHeapSnapshot()', function(done) {
     }).then(client => {
       client.api.takeHeapSnapshot('snap.heapsnapshot', function(result) {
         assert.strictEqual(result.status, -1);
-        assert.strictEqual(result.error, 'TakeHeapSnapshot is only supported in Chrome and Edge drivers');
+        assert.strictEqual(result.error, 'The command .takeHeapSnapshot() is only supported in Chrome and Edge drivers');
       });
       client.start(done);
     });