c3b5d3d649431b9ea8bfced1eb5906780f83e8b6
[yaffs-website] / web / core / tests / Drupal / Nightwatch / Commands / drupalLogAndEnd.js
1 /**
2  * Ends the browser session and logs the console log if there were any errors.
3  * See globals.js.
4  *
5  * @param {Object}
6  *   (optional) Settings object
7  *   @param onlyOnError
8  *     (optional) Only writes out the console log file if the test failed.
9  * @param {function} callback
10  *   A callback which will be called.
11  * @return {object}
12  *   The 'browser' object.
13  */
14 exports.command = function drupalLogAndEnd({ onlyOnError = true }, callback) {
15   const self = this;
16   this.drupalLogConsole = true;
17   this.drupalLogConsoleOnlyOnError = onlyOnError;
18
19   // Nightwatch doesn't like it when no actions are added in a command file.
20   // https://github.com/nightwatchjs/nightwatch/issues/1792
21   this.pause(1);
22
23   if (typeof callback === 'function') {
24     callback.call(self);
25   }
26   return this;
27 };