This is a test D8 site which can be used for practicing test writing and running. This is to be used in tandem with the Testing. Testing. 1... 2... 3... tap tap tap - Is this thing on? training at TexasCamp 2019.
You'll need the following installed on your system:
- Bash or some other comparable shell
- git
- PHP 7.1-7.3
- Composer
- Sqlite
- Node.js 8+
- yarn
- Google Chrome
-
Fork the https://github.com/WidgetsBurritos/test-d8-site repo.
-
Clone your fork locally and change into that directory.
-
Install dependencies:
composer install
-
Determine your version of Google Chrome (e.g. 77.0.3865.90)
-
Install the nightwatch dependencies (note: you need to set your major chrome version)
export CHROMEVERSION=77 cd web/core yarn install yarn remove chromedriver yarn add chromedriver@${CHROMEVERSION} cp -f .env.example .env cd ../..
-
Do a basic site install based on the existing config:
vendor/bin/drush si my_profile -y --db-url=sqlite://sites/example.com/files/.ht.sqlite --config-dir=../config/sync --account-pass=admin
-
Create some more users and set roles
vendor/bin/drush user:create bobby --mail="[email protected]" --password="bobby" vendor/bin/drush user:create carol --mail="[email protected]" --password="carol" vendor/bin/drush user:create david --mail="[email protected]" --password="david" vendor/bin/drush user-add-role "administrator" admin vendor/bin/drush user-add-role "super_secret" bobby vendor/bin/drush user-add-role "yet_another_role" carol
-
Start a local web server:
cd web php -S localhost:8888 .ht.router.php
-
Open the site in your browser:
open http://localhost:8888
-
At this point you can run a quick test to see if you have everything setup correctly by running:
composer run check:dependencies
-
my_testing_module: Most of what we will be working with is located in a custom module called my_testing_module. Go to that module's README to find out more information about what it does.
-
simpletest: This module is provided by Drupal core. This test will be used for kernel, functional, and javascript tests. It also provides a UI in the admin panel that can be used to run tests (although we will be focused on test running via the command line).
php ./web/core/scripts/run-tests.sh --color --verbose --url 'http://localhost:8888' my_testing_module
php ./web/core/scripts/run-tests.sh --color --verbose --url 'http://localhost:8888' --class 'Drupal\Tests\my_testing_module\Functional\MyFunctionalTest'
If you are only running unit/kernel tests, you can leave off --url 'http://localhost:8888'
.
The first time you attempt to run nightwatch.js please ensure you follow the getting started instructions above and ensure that composer run check:dependencies
runs as expected.
cd web/core
export DRUPAL_TEST_BASE_URL=http://localhost:8888
yarn test:nightwatch ../modules/custom/my_testing_module/tests/src/Nightwatch
cd web/core
export DRUPAL_TEST_BASE_URL=http://localhost:8888
yarn test:nightwatch ../modules/custom/my_testing_module/tests/src/Nightwatch/MyNightwatchTest.js
BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "http://localhost:8888"}}}' ./vendor/bin/behat