Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / README.md
index fcaa5cc2c2d54efaa5e0a5701ef4bcdcd4340353..0ea2efc9ba4e36186c6a8594aee927d7845896e6 100644 (file)
@@ -13,6 +13,11 @@ Note: functional tests have to be invoked with a user in the same group as the
 web server user. You can either configure Apache (or nginx) to run as your own
 system user or run tests as a privileged user instead.
 
+Invoking tests with a user that is in the same group as the web server will
+require you to ensure Drupal keeps gid stickybits when creating new directories.
+
+`$settings['file_chmod_directory'] = 02775;`
+
 To develop locally, a straightforward - but also less secure - approach is to
 run tests as your own system user. To achieve that, change the default Apache
 user to run as your system user. Typically, you'd need to modify
@@ -102,3 +107,34 @@ export SIMPLETEST_BASE_URL='http://d8.dev'
 sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional
 sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional-javascript
 ```
+
+## Nightwatch tests
+
+- Ensure your vendor directory is populated (e.g. by running `composer install`)
+- If you're running PHP 7.0 or greater you will need to upgrade PHPUnit with `composer run-script drupal-phpunit-upgrade`
+- Install [Node.js](https://nodejs.org/en/download/) and [yarn](https://yarnpkg.com/en/docs/install). The versions required are specificed inside core/package.json in the `engines` field
+- Install [Google Chrome](https://www.google.com/chrome/browser/desktop/index.html)
+- Inside the `core` folder, run `yarn install`
+- Configure the nightwatch settings by copying `.env.example` to `.env` and editing as necessary.
+- Ensure you have a web server running (as instructed in `.env`)
+- Again inside the `core` folder, run `yarn test:nightwatch` to run the tests. By default this will output reports to `core/reports`
+- Nightwatch will run tests for core, as well as contrib and custom modules and themes. It will search for tests located under folders with the pattern `**/tests/**/Nightwatch/(Tests|Commands|Assertions)`
+- To run only core tests, run `yarn test:nightwatch --tag core`
+- 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:
+```
+tests/Nightwatch/Tests
+src/tests/Nightwatch/Tests
+tests/src/Nightwatch/Tests
+tests/Nightwatch/Commands
+```
+
+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`.
+The Nightwatch configuration, as well as global tests, commands, and assertions which span many modules/systems, are located in `core/tests/Drupal/Nightwatch`.
+
+If your core directory is located in a subfolder (e.g. `docroot`), then you can edit the search directory in `.env` to pick up tests outside of your Drupal directory.
+Tests outside of the `core` folder will run in the version of node you have installed. If you want to transpile with babel (e.g. to use `import` statements) outside of core,
+then add your own babel config to the root of your project. For example, if core is located under `docroot/core`, then you could run `yarn add babel-preset-env` inside
+`docroot`, then copy the babel settings from `docroot/core/package.json` into `docroot/package.json`.