annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 // A custom Nightwatch assertion.
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 // The assertion name is the filename.
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 // Example usage:
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4 //
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 // browser.assert.elementCount(selector, count)
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
6 //
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
7 // For more information on custom assertions see:
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 // http://nightwatchjs.org/guide#writing-custom-assertions
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
10 exports.assertion = function elementCount(selector, count) {
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 this.message = `Testing if element <${selector}> has count: ${count}`;
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 this.expected = count;
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 this.pass = val => val === count;
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14 this.value = res => res.value;
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
15 function evaluator(_selector) {
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 return document.querySelectorAll(_selector).length;
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
17 }
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18 this.command = cb => this.api.execute(evaluator, [selector], cb);
7c40e9f28f94 test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
19 };