diff --git a/.circleci/config.yml b/.circleci/config.yml index f6dc6f6..1a4572a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,8 +99,9 @@ jobs: - run: name: Run Behat tests command: | - nohup php -S ${CIRCLE_PROJECT_REPONAME}.local:8000 -t $(pwd)/web/ > /tmp/artifacts/phpd.log 2>&1 & - vendor/bin/behat --profile=circleci --suite=default --strict --format=junit --out=/tmp/artifacts + nohup php -S ${CIRCLE_PROJECT_REPONAME}.local:8000 -t $(pwd)/web/ > /tmp/artifacts/phpd.log 2>&1 & + google-chrome --headless --remote-debugging-port=9222 &>/dev/null & + vendor/bin/behat --profile=circleci --suite=default --strict --format=junit --out=/tmp/artifacts - store_artifacts: path: /tmp/artifacts - store_test_results: diff --git a/.ddev/docker-compose.chrome.yaml b/.ddev/docker-compose.chrome.yaml new file mode 100644 index 0000000..19af9b6 --- /dev/null +++ b/.ddev/docker-compose.chrome.yaml @@ -0,0 +1,21 @@ +# This was taken from https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/headless-chrome. +version: '3.6' +services: + chrome: + image: isholgueras/chrome-headless:latest + restart: unless-stopped + container_name: ddev-${DDEV_SITENAME}-chrome + labels: + com.ddev.site-name: ${DDEV_SITENAME} + com.ddev.approot: $DDEV_APPROOT + volumes: + - ddev-global-cache:/mnt/ddev-global-cache + - ".:/mnt/ddev_config" + external_links: + - "ddev-router:${DDEV_HOSTNAME}" + cap_add: + - SYS_ADMIN + ports: + # Exposing this port allows you to visit 127.0.0.1:9222 to see what Headless Chrome doing without + # any additional configuration; However, you can only have one project using this port at a time. + - '9222:9222' \ No newline at end of file diff --git a/behat.yml b/behat.yml deleted file mode 100644 index 4761faf..0000000 --- a/behat.yml +++ /dev/null @@ -1,36 +0,0 @@ -default: - suites: - default: - contexts: - - FeatureContext - - Drupal\DrupalExtension\Context\DrupalContext - - Drupal\DrupalExtension\Context\MinkContext - - Drupal\DrupalExtension\Context\MessageContext - - Drupal\DrupalExtension\Context\DrushContext - filters: - tags: "~@skipci" - gherkin: - cache: ~ - extensions: - Behat\MinkExtension: - goutte: ~ - selenium2: - wd_host: "http://127.0.0.1:8643/wd/hub" - javascript_session: selenium2 - base_url: http://drupal-skeleton.local - Drupal\DrupalExtension: - blackbox: ~ - api_driver: 'drupal' - drupal: - drupal_root: 'docroot' - text: - username_field: 'name' - password_field: 'pass' - log_out: 'Log out' - region_map: - anywhere: "*" - -circle: - extensions: - Behat\MinkExtension: - base_url: http://drupal-skeleton.local:8000 diff --git a/composer.json b/composer.json index cf4e60a..7ba4502 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,9 @@ "drush/drush": "^11" }, "require-dev": { + "behat/behat": "^3.12", "behat/mink-goutte-driver": "^2.0", + "dmore/behat-chrome-extension": "^1.4", "drupal/core-dev": "^10", "drupal/drupal-extension": "^5@alpha", "palantirnet/the-build": "^4@beta" diff --git a/features/js_behat_test.feature b/features/js_behat_test.feature new file mode 100644 index 0000000..720d2f4 --- /dev/null +++ b/features/js_behat_test.feature @@ -0,0 +1,12 @@ +@api @javascript +Feature: Installation + As a Drupal developer + I want to use javaScript in Behat tests + So that I can rely on the build for my project. + + Scenario: Verify that js behat test works. + Given I am logged in as a user with the "administrator" role + When I am on "/admin/modules/update" + And I should see the link "Check manually" + And I click "Check manually" + Then I should see the text "Status message"