Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,32 @@ This will trigger the setup and teardown of the separate Drupal site.

If you have a test that you don't want to run this way, import test and expect from `@playwright/test` as normal.

### Recording tests in VS Code

The VS Code “Record new” command generates absolute URLs and default imports. To keep URLs relative and use `@lullabot/playwright-drupal` helpers, record **at cursor** into a test file.

1. Create a test from the following template:

```ts
// test/playwright/e2e/test1.spec.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! I haven't used the Playwright VS Code extension, but it looks like it could be useful. By default, playwright.config.ts is configured to look for tests only in the test/playwright/tests/ directory:

  testDir: './tests',

How about we instead recommend to put this in tests rather than e2e?

import { test, expect, execDrushInTestSite } from '@packages/playwright-drupal';

// 1. Update the test name.
test('new test', async ({ page }) => {
// 2. Keep paths relative; "Record new" would supply the absolute URL.
await page.goto('/');
// 3. Place cursor here, then use "Record at cursor"
});
```

2. In the VS Code Testing sidebar, under Playwright:

* Scroll to and toggle the correct configs (gear icon) pointing to your project's `test/playwright/playwright.config.ts`.
* Use **Record at cursor** to append steps into the template.
(If the recorder adds an extra absolute `page.goto('http://…')`, change it to keep them relative `/`.)

This keeps tests portable across DDEV/CI, leverages `use.baseURL`, and ensures Lullabot helpers are available.

## Visual Comparisons (Diffs)

Playwright Visual Comparisons are a great way to add additional assertions to your tests. Since visual comparisons are integrated into the testing system, developers can compare all aspects of a site - including content forms or other authenticated content.
Expand Down