Chris@17: /** Chris@17: * Ends the browser session and logs the console log if there were any errors. Chris@17: * See globals.js. Chris@17: * Chris@17: * @param {Object} Chris@17: * (optional) Settings object Chris@17: * @param onlyOnError Chris@17: * (optional) Only writes out the console log file if the test failed. Chris@17: * @param {function} callback Chris@17: * A callback which will be called. Chris@17: * @return {object} Chris@17: * The 'browser' object. Chris@17: */ Chris@17: exports.command = function drupalLogAndEnd({ onlyOnError = true }, callback) { Chris@17: const self = this; Chris@17: this.drupalLogConsole = true; Chris@17: this.drupalLogConsoleOnlyOnError = onlyOnError; Chris@17: Chris@17: // Nightwatch doesn't like it when no actions are added in a command file. Chris@17: // https://github.com/nightwatchjs/nightwatch/issues/1792 Chris@17: this.pause(1); Chris@17: Chris@17: if (typeof callback === 'function') { Chris@17: callback.call(self); Chris@17: } Chris@17: return this; Chris@17: };