githubEdit

Automated Testing

Varbase 11.0.x includes a comprehensive automated functional acceptance testing suite built with Playwrightarrow-up-right, Cucumber-JSarrow-up-right, and Webship-jsarrow-up-right.

Overview

The testing suite provides end-to-end testing of Varbase features using Behaviour-Driven Development (BDD). Tests are written in plain language (Gherkin syntax) making them readable by all team members, and are executed against real browser instances.

Technology Stack

Tool
Role

Browser automation and end-to-end testing framework. Supports Chromium, Firefox, and WebKit.

BDD test runner that executes tests written in Gherkin (Given/When/Then) plain language syntax.

Automated functional acceptance testing tool with pre-built step definitions for Drupal Core and Drupal CMS.

Prerequisites

  • DDEVarrow-up-right local development environment

  • Node.js >= 20

  • Yarn 4 (enabled via corepack)

Quick Start

Fresh Build (New Site)

Already Installed Site

DDEV Commands for Testing Varbase

ddev install-varbase

Installs Varbase from scratch using drush site:install varbase with the Varbase profile and Drupal recipes.

ddev init-full-automated-testing

Full initialization for automated testing. Handles everything from a fresh ddev start:

  1. Installs Varbase if the database is empty

  2. Applies optional Varbase recipes (varbase_dev_base, varbase_i18n_base, varbase_api_base, varbase_auth_base, varbase_ai_base)

  3. Enables social auth modules (social_auth_facebook, social_auth_linkedin)

  4. Adds testing users for each Varbase role

  5. Disables the antibot module (required for automated browser testing)

  6. Disables CSS/JS aggregation

  7. Sets verbose error logging

ddev init-minimal-automated-testing

Minimal initialization for automated testing on an already installed site. Does not install Varbase or apply recipes:

  1. Verifies Drupal is installed (exits with error if not)

  2. Adds testing users for each Varbase role

  3. Disables the antibot module

  4. Disables CSS/JS aggregation

  5. Sets verbose error logging

ddev add-testing-users / ddev delete-testing-users

Manage testing user accounts individually.

Running Tests

Running Specific Tests

Test Structure

Step definitions from Webship-jsarrow-up-right are loaded automatically from node_modules/webship-js/tests/step-definitions/.

Test Suites

01 - Website Base Requirements

Feature
Description

Welcome Tour

Admin dashboard displays after login

User Registration

Only admins can register new users

User Roles

Default roles (Content editor, Content Admin, SEO Admin, Site Admin, Super Admin) are present

Input Formats

Rich text editor formats are available to authorized users

Website Languages

Internationalization configuration is accessible

Accessibility Checker

Editoria11y accessibility checker permissions

02 - User Management

Feature
Description

Request New Password

Password reset functionality

Create Users and Assign Roles

Site admins can create accounts and assign roles

User Login

Login functionality for existing accounts

Persistent Login

Session persistence during browser sessions

User Protect

User account protection for admin accounts

Role Assign

Role assignment permissions and delegation

Login Redirect

Admin roles redirect to dashboard, authenticated users to profile

03 - Admin Management

Feature
Description

Admin Pages

Pre-check of important admin and development pages

Masquerade

Site admins can switch users to view the site as another user

Keyboard Navigation

Navigate admin with Coffee module keyboard shortcut

Disable Users

Admins can block user accounts

Media Usage

Image media and usage list page for admins

JSON:API

JSON:API admin interface and services checks

Audit Trail

Admin audit trail access permissions

Media Bulk Upload

Media bulk upload access permissions

04 - Content Structure

Feature
Description

Page Permissions

Page content type permissions by role

Canvas Pages

Canvas page builder permissions

Breadcrumbs

Standard breadcrumb navigation

Blog Permissions

Blog post content type permissions by role

Blog Page

Blog listing page renders correctly

Contact Us

Contact form page is accessible

Homepage

Homepage loads and displays expected content

Canvas Editor

Drupal Canvas visual page editor access

05 - Content Management

Feature
Description

Entityqueues

Entityqueue management permissions

Cloning

Content and entity cloning via Entity Clone

Media Library

Media library access permissions

Linkit

Internal content linking configuration

Content Workflows

Content moderation workflow configuration

Content Scheduling

Scheduled publishing and unpublishing

Trash Management

Soft-deleted content management

Testing Users

The following test users are created during testing initialization:

Username
Email
Role

webmaster

administrator

Normal user

authenticated

Content editor

content_editor

Content admin

content_admin

SEO admin

seo_admin

Site admin

site_admin

Super admin

administrator

All test user passwords: dD.123123ddd

Configuration Files

Cucumber-JS configuration file defining:

  • Test timeout (40 seconds)

  • Step definition paths (Webship-js + Varbase custom)

  • Feature file paths

  • World parameters (launch URL, wait times, test user credentials)

The launchUrl defaults to the LAUNCH_URL environment variable, then DDEV_PRIMARY_URL, then https://localhost.

Playwright browser configuration:

  • Headless mode enabled by default

  • SlowMo set to 300ms for stability

  • HTTPS certificate errors ignored (for DDEV self-signed certs)

  • Chromium launched with sandbox disabled for CI compatibility

  • Browser selected via the BROWSER environment variable (defaults to chromium)

Example Local Varbase Automated Testing with DDEV

To See the Test in Your local Browser

1- Change headless: true, to headless: false, in the playwright.config.js file.

2- Change to launchUrl: 'https://my-varbase-site.ddev.site', in the cucumber.js file.

3- Run in your local development, not with DDEV

Custom Step Definitions

Varbase provides custom step definitions in tests/step-definitions/varbase-step-definitions.js that extend the Webship-js base:

Step
Example

Login as a configured user

Given I am a logged in user with the "Content admin" user

Browse as anonymous

Given I am an anonymous user

Check a checkbox by label

When I check the box "Remember me"

Assert checkbox checked

Then I should see the "Remember me" checkbox checked

Assert checkbox unchecked

Then I should see the "Remember me" checkbox unchecked

Wait for page load

And wait

Click tour next button

When I click next button in tour

Assert element in container

Then I should see the "#edit-title" element in the ".form-wrapper" field

Assert element not in container

Then I should not see the "#edit-title" element in the ".form-wrapper" field

Additional step definitions are loaded from Webship-jsarrow-up-right which provides a comprehensive library of Drupal-aware steps for navigation, forms, content, media, and more.

Writing New Tests

Feature files use Gherkin syntax. Each scenario describes a user story with Given/When/Then steps:

Tags

Tests use tags to control execution scope:

Tag
Purpose

@javascript

Requires browser execution

@check

Quick verification tests

@local

Suitable for local development

@development

Suitable for development environments

@staging

Suitable for staging environments

@production

Suitable for production (read-only checks)

Place new feature files in the appropriate numbered directory under tests/features/ following the existing naming convention.

Last updated