Install Automated Testing Kit and Its Dependencies

The following instructions are for an initial install and are suitable for an existing site. The Automated Testing Kit Recipe may work, too. See the Applying the Automated Testing Kit Recipe page if you want to try it or simple want to create a vanilla Drupal site to experiment with Automated Testing Kit.

For help with installation, visit the  #automated_testing_kit room of the Slack Drupal workspace.

Install only the dependencies needed by the tests you want to run.  

Drush: (required) Drush is required for many utility functions in Automated Testing Kit.

QA Accounts: Allows you to use accounts available to the QA team. You can alter the qaUsers.txt file to use other accounts and avoid installing this module.

Symfony Mailer: Include this to send emails as part of your tests (use another mailer if you wish).

Webform: Include this to test the Contact us form.

XML Sitemap: Include this to test the sitemaps generated by XML Sitemap.

Feeds: Include this to test Feeds.

Open the composer.json file in the project root directory and add the following to the list of required modules:

"drupal/automated_testing_kit": "^1.0",
"drupal/qa_accounts": "^1.0",
"drupal/symfony_mailer": "^1.0",
"drupal/webform": "^6.0",
"drupal/xmlsitemap": "^1.0",
"drush/drush": "^12"

Then update with:

rm composer.lock
composer update

Or, from the command line use composer require for each module above that you'll need according to the tests you want to run in this form:

composer require drupal/automated_testing_kit

Visit Installing Modules for further information.

Enable Automated Testing Kit in Drupal

Using the Drupal GUI

Go to admin/modules, set the checkbox for Automated Testing Kit, QA Accounts, Symfony Mailer, Web Form and XML Sitemap then click the Install button.

Using Drush

Run the following to enable the modules.

drush -y en automated_testing_kit media media_library qa_accounts symfony_mailer webform xmlsitemap

Uninstallation

Uninstall the module through admin/modules/uninstall. Currently, Automated Testing Kit does not add tables or configuration.

Or use Drush:

drush -y pm:uninstall automated_testing_kit qa_accounts symfony_mailer webform xmlsitemap

Install Tests and Test Framework

When installing Cypress or Playwright for development, install them in the native OS. If you install them in a container, the GUI won't be available to you. 

The atk_setup script will help you to install (copy) the tests, test framework configuration and dependencies to the proper location.

With atk_setup, set the argument to cypress or playwright depending on the testing framework you are using. 

atk_setup copies the tests, configuration files and support files to the default locations for the framework.

To change the location where the tests will be copied, execute the following before running the script:

export ATK_HOME=./my/test/dir

This is the setup script:

cd <project root> 
web/modules/contrib/automated_testing_kit/module_support/atk_setup cypress|playwright [link]

You will see something like this:

== Setting up for Cypress. ==
Copying cypress.atk.config.js to <project_root>/cypress.atk.config.js.
Copying or linking tests to <project_root>/cypress/e2e.
Copying or linking data files to <project_root>/cypress.
Copying or linking test framework support files to <project_root>/cypress.

Install dependencies

Beside of tests, test data and support files, atk_setup script copies package.json for the chosen framework. To install dependencies, run

npm i

For Playwright, you may need to install browsers separately with the command:

npx playwright install

Playwright

atk_setup playwright will copy the files to:

• configuration files --> <project_root>
• tests               --> <project_root>/tests
• data files          --> <project_root>/tests/data
• support files       --> <project_root>/tests/suppor
Support files include atk_commands.js, which holds many of the common functions related to Playwright, and atk_utilities.js, which holds general utility functions.

Cypress

atk_setup cypress will copy the files to:

• configuration files --> <project_root>
• tests               --> <project_root>/cypress/e2e
• data files          --> <project_root>/cypress/data
• support files       --> <project_root>/cypress/support
Support files include atk_commands.js, which holds many of the common functions related to Cypress, and atk_utilities.js, which holds general utility functions.

Contributing to Automated Testing Kit

See Contributing to Automated Testing Kit.

Upgrading Automated Testing Kit

The goal is to make new releases within the same major version number backwards compatible.

Install Optional Dependencies for Cypress

cypress-log-to-term: Cypress relies on cypress-log-to-term for replicating cy.log messages to the console.

@cypress/grep: (optional and recommended) This Cypress plugin allows you to select tests to run by tag.

bahmutov/cypress-slow-down: (optional and recommended) This Cypress plugin allows you to slow down test runs to make debugging easier. To use the plugin, see the instructions on its project page.

Follow corresponding modules' installation instructions to install them.