Install Automated Testing Kit and Its Dependencies

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.

(under construction) Routes List: Test all available routes.

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/routes_list": "^6.2",
"drupal/symfony_mailer": "^1.0",
"drupal/webform": "^6.0",
"drupal/xmlsitemap": "^1.0",
"drush/drush": "^12"

If you are going to use the Routes List test, ensure Composer can apply patches by adding the composer-patches plugin. Then add the patch to the composer.json file:

composer config allow-plugins.cweagans/composer-patches true
composer require cweagans/composer-patches
composer config extra.enable-patching true
composer config extra.patches --merge --json '{"drupal/routes_list": {"Add JSON response to routes_list.": "web/modules/contrib/automated_testing_kit/module_support/patches/routes_list_add_json.patch"}}'

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:

composer require drupal/automated_testing_kit

Visit Installing Modules for further information.

Install Cypress or Playwright

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. 

Instructions to install Playwright are here and instructions to install Cypress are here.

These instructions and accompanying configuration files assume that you are installing in the same directory as the project. 

When using Docker, use containers maintained by Cypress or maintained by Microsoft.

Playwright

When installing Playwright, choose Javascript for this prompt: 

✔ Do you want to use TypeScript or JavaScript?

This will give you the a config.js file rather than a config.ts configuration file.

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

Run atk_setup

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. If you want to link the files instead of copying them, add "link" to the command. However, be aware that debugging in your IDE may not work with linking. If you are using non-default locations (such as "html" instead of "web," edit the setup script first.

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.

Playwright

atk_setup playwright will copy or link 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 or link 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 Dependencies for Cypress

cypress-log-to-term: Cypress relies on cypress-log-to-term for better logging.

@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.

Add the following to the package.json:

  "dependencies": {
"cypress": "^13",
"cypress-log-to-term": "^1",
"@cypress/grep": "^4",
"cypress-slow-down": "^1",
"fast-xml-parser": "^4"
}

Then run:

npm update

Install Dependencies for Playwright

Install the following packages:

npm install dotenv fast-xml-parser axios