diff client/tests/e2e/custom-assertions/elementCount.js @ 164:7c40e9f28f94

test: Moved testfile. Established nightwatch tests Vue-cli offers easy e2e test integration with nightowl. Nightowl leverages the selenium webdriver. So the bedrock for a test suite is laid. Additionally: Upgraded packages of vue-cli, which are now at least Release Candidates.
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 06 Jul 2018 10:51:19 +0200
parents
children 0c5cbbafbd94
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/tests/e2e/custom-assertions/elementCount.js	Fri Jul 06 10:51:19 2018 +0200
@@ -0,0 +1,19 @@
+// A custom Nightwatch assertion.
+// The assertion name is the filename.
+// Example usage:
+//
+//   browser.assert.elementCount(selector, count)
+//
+// For more information on custom assertions see:
+// http://nightwatchjs.org/guide#writing-custom-assertions
+
+exports.assertion = function elementCount(selector, count) {
+  this.message = `Testing if element <${selector}> has count: ${count}`;
+  this.expected = count;
+  this.pass = val => val === count;
+  this.value = res => res.value;
+  function evaluator(_selector) {
+    return document.querySelectorAll(_selector).length;
+  }
+  this.command = cb => this.api.execute(evaluator, [selector], cb);
+};