Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Nightwatch / Commands / drupalLogAndEnd.js
diff --git a/web/core/tests/Drupal/Nightwatch/Commands/drupalLogAndEnd.js b/web/core/tests/Drupal/Nightwatch/Commands/drupalLogAndEnd.js
new file mode 100644 (file)
index 0000000..c3b5d3d
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * Ends the browser session and logs the console log if there were any errors.
+ * See globals.js.
+ *
+ * @param {Object}
+ *   (optional) Settings object
+ *   @param onlyOnError
+ *     (optional) Only writes out the console log file if the test failed.
+ * @param {function} callback
+ *   A callback which will be called.
+ * @return {object}
+ *   The 'browser' object.
+ */
+exports.command = function drupalLogAndEnd({ onlyOnError = true }, callback) {
+  const self = this;
+  this.drupalLogConsole = true;
+  this.drupalLogConsoleOnlyOnError = onlyOnError;
+
+  // Nightwatch doesn't like it when no actions are added in a command file.
+  // https://github.com/nightwatchjs/nightwatch/issues/1792
+  this.pause(1);
+
+  if (typeof callback === 'function') {
+    callback.call(self);
+  }
+  return this;
+};