drupalLogAndEnd.js 799 B

123456789101112131415161718192021222324252627
  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. // Nightwatch doesn't like it when no actions are added in a command file.
  19. // https://github.com/nightwatchjs/nightwatch/issues/1792
  20. this.pause(1);
  21. if (typeof callback === 'function') {
  22. callback.call(self);
  23. }
  24. return this;
  25. };