Skip to content

adding playwright VRT integration#86

Open
rigoucr wants to merge 4 commits into
3.xfrom
feature/playwright-vrt
Open

adding playwright VRT integration#86
rigoucr wants to merge 4 commits into
3.xfrom
feature/playwright-vrt

Conversation

@rigoucr

@rigoucr rigoucr commented May 27, 2026

Copy link
Copy Markdown
Contributor

Functional Testing Instructions
Run these from the Drupal project root.

  • Install the dev version from this PR branch:
composer remove fourkitchens/fire
composer require fourkitchens/fire:"dev-feature/playwright-vrt" --dev --prefer-source
./vendor/fourkitchens/fire/bin/fire --version
  • Set the Playwright test root:
    export ATK_HOME=./tests/playwright
  • Run the Playwright init command:
    ./vendor/fourkitchens/fire/bin/fire vrt:init
  • At the prompts, enter test values such as:
BASELINE_URL="https://mysite.com"
CANDIDATE_URL="http://mylocalsite.lndo.site"
BASELINE_TERMINUS_ENV=live
BASELINE_TERMINUS_SITE=my-site
  • Verify generated files exist:
ls tests/playwright/.env
ls tests/playwright/package.json
ls tests/playwright/playwright.config.js
ls tests/playwright/playwright.atk.config.js
  • Verify .env content:
cat tests/playwright/.env
Expected:
BASELINE_URL="https://mysite.live"
CANDIDATE_URL="http://mysite.lndo.site"
BASELINE_TERMINUS_ENV=live
BASELINE_TERMINUS_SITE=my-site
  • Verify npm scripts were added:
cd tests/playwright
npm pkg get scripts

Expected scripts include:

{
  "vrt": "playwright-vrt",
  "vrt:local": "playwright-vrt-local",
  "vrt:ci": "playwright-vrt-ci"
}
  • Verify Playwright VRT runs through FIRE:
cd ../..
./vendor/fourkitchens/fire/bin/fire vrt:run --tool=playwright
11. Verify reference command uses the Playwright npm script:
./vendor/fourkitchens/fire/bin/fire vrt:reference --tool=playwright
12. Verify automatic tool detection:
./vendor/fourkitchens/fire/bin/fire vrt:run
./vendor/fourkitchens/fire/bin/fire vrt:reference

Expected:

  • If only Playwright is configured, FIRE runs Playwright automatically.
  • If both Backstop and Playwright are configured, FIRE asks which tool to run.
  • With --no-interaction, FIRE defaults to Playwright when both are configured.
  1. Optional direct npm verification:
cd tests/playwright
npm run vrt

@rigoucr rigoucr changed the title Updating Fire commands - adding playwright VRT integration adding playwright VRT integration May 27, 2026
@rigoucr rigoucr marked this pull request as ready for review June 16, 2026 15:58
@rigoucr rigoucr self-assigned this Jun 16, 2026
*/
require('dotenv').config();

const configuredBaseURL = (process.env.REMOTE_ENV_BASE_URL || '__DEFAULT_BASE_URL__')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file reads process.env.REMOTE_ENV_BASE_URL to set the base URL. But the .env file the command generates writes CANDIDATE_URL and BASELINE_URL Mismatch?

Comment thread README.md
```

The `.env` file is added to `tests/playwright/.gitignore` by the init command.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add a part here where we describe how to edit the common pages.

@@ -0,0 +1,46 @@
const { devices } = require('@playwright/test')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're mixing 'require' and 'export' in the same file. We should pick one standard.


const images = Array.from(document.querySelectorAll('img[loading="lazy"]'))

for (const image of images) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, for loops can be slow sequence. Since this is JS we can fire these off in parallel and just await the work to be done.

$this->taskExec($command)->run();
}
else {
$this->taskExec($env . ' npm install')->dir($testsRoot)->run();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to trace these commands back, including the init/install and reference commands. Some of them run in DDEV and other run on NPM. This worked for me because I already had playwright installed locally, but I'm not sure the logic is sound here. Maybe someone else can test from a clean install.

$drupalRoot = $this->getDrupalRoot();
$atkHome = getenv('ATK_HOME');
if (!$atkHome) {
throw new AbortTasksException('ATK_HOME is not set in your environment. Add `export ATK_HOME=./tests/playwright` to your shell profile (PATH) and rerun.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused by this. We are telling them to set a path, but it has to be this specific path. Can we simply hardcode the path? If not, should we remove the hardcoded value in the 'run' command?

@nJim nJim left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the work, but added a number of comments to consider as future changes. In general I would say the direction is good. Backstop is aging and Playwright is a better long term fit. I also understand wanting to put this into Fire to help with adoption.

I had trouble getting this running locally, which surfaced how many moving parts there are and how hard failures are to debug. We have:

  • composer required modules
  • ATK to run scaffolding
  • FIRE to copy templates, set ENVs, update files
  • NPM to install packages and browsers
  • CLI scripts that sometimes call other CLI script

I think this orchestration is going to make this very difficult to roll out. A proven template (tests/playwright) could simply be copied to every project with a readme to explain how to use it.

I think this effort looks like it's more about the automation of setup than the testing itself. The configuration does not exactly look correct (timeout, retry, possibly recording all traces.) Some variables are inconsistent (hardcoded vs configurable, ATK_HOME only works for init but not run). I think we can get this a little tighter before pushing for a every-site rollout. Or maybe try one site at a time and see what we learn.

Great work on moving this project forward. I think we can merge this as a big step towards the larger rollout.

* @option $y Run the command with no interection required.
*
*/
public function vrtInit(ConsoleIO $io) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vrt:init calls vrt:playwright:init feels strange on the command line. If we are depricating backstop, why even support new installations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants