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.
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.
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.
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. Use the rest of the defaults.
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 are using non-default locations (such as "html" instead of "web,") change WEB_ROOT_DIR in the setup script first.
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.
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 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