Skip to content
Snippets Groups Projects
Unverified Commit a0475565 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2981602 by jansete, Lendude, askibinski, alexpott, dawehner, slv_,...

Issue #2981602 by jansete, Lendude, askibinski, alexpott, dawehner, slv_, Sam152: Add page objects integration to Nightwatch
parent d540d8d6
No related branches found
No related tags found
No related merge requests found
module.exports = {
props: {
text: 'Test page text',
timeout: 1000,
},
elements: {
body: {
selector: 'body',
},
},
};
......@@ -15,4 +15,13 @@ module.exports = {
.assert.containsText('body', 'Test page text')
.drupalLogAndEnd({ onlyOnError: false });
},
'Page objects test page': browser => {
const testPage = browser.page.TestPage();
testPage
.drupalRelativeURL('/test-page')
.waitForElementVisible('@body', testPage.props.timeout)
.assert.containsText('@body', testPage.props.text)
.drupalLogAndEnd({ onlyOnError: false });
},
};
......@@ -7,6 +7,7 @@ const collectedFolders = {
Tests: [],
Commands: [],
Assertions: [],
Pages: [],
};
const searchDirectory = process.env.DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY || '';
......@@ -45,7 +46,7 @@ module.exports = {
output_folder: process.env.DRUPAL_NIGHTWATCH_OUTPUT,
custom_commands_path: collectedFolders.Commands,
custom_assertions_path: collectedFolders.Assertions,
page_objects_path: '',
page_objects_path: collectedFolders.Pages,
globals_path: 'tests/Drupal/Nightwatch/globals.js',
selenium: {
start_process: false,
......
......@@ -123,12 +123,14 @@ sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional-javascri
- To skip running core tests, run `yarn test:nightwatch --skiptags core`
- To run a single test, run e.g. `yarn test:nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js`
Nightwatch tests can be placed in any folder with the pattern `**/tests/**/Nightwatch/(Tests|Commands|Assertions)`. For example:
Nightwatch tests, as well as custom commands, assertions and pages, can be placed in any folder with the pattern `**/tests/**/Nightwatch/(Tests|Commands|Assertions|Pages)`. For example:
```
tests/Nightwatch/Tests
src/tests/Nightwatch/Tests
tests/src/Nightwatch/Tests
tests/Nightwatch/Commands
tests/src/Nightwatch/Assertions
tests/src/Nightwatch/Pages
```
It's helpful to follow existing patterns for test placement, so for the action module they would go in `core/modules/action/tests/src/Nightwatch`.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment