Skip to content

Commit 4b9fd40

Browse files
committed
improve architecture docs + clarify responsibilities
1 parent 944bc18 commit 4b9fd40

16 files changed

Lines changed: 81 additions & 538 deletions

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Run Playwright browser tests while intercepting HTTP requests and routing them t
1717
Traditional E2E testing requires running a separate web server. This bundle eliminates that overhead:
1818

1919
- **In-Process Request Handling**: HTTP requests from the browser are handled by your Symfony kernel in the same PHP process
20+
- **DomCrawler Integration**: Use familiar Symfony `Crawler`, `Link`, and `Form` objects while driving a real browser
2021
- **Full Symfony Integration**: Access services, the profiler, events, and database state during tests
2122
- **Fast Asset Serving**: Static assets and AssetMapper files bypass the kernel for optimal performance
2223
- **Real Browser Testing**: Test with Chromium, Firefox, or WebKit using Playwright
23-
- **Session & Auth Helpers**: Built-in cookie management and authentication helpers
24-
- **Request Inspection**: Access intercepted HTTP requests and responses in your tests
24+
- **Shared Browser Session**: Optimized architecture reuses the same browser process across tests for maximum speed
2525

2626
## Installation
2727

@@ -34,14 +34,15 @@ composer require --dev playwright-php/playwright-symfony
3434
**Requirements:**
3535
- PHP 8.3+
3636
- Symfony 7.0+ or 8.0+
37-
- Node.js 18+ (for Playwright browser communication)
37+
- Node.js 20+ (for Playwright browser communication)
3838

39-
**Install Playwright browsers:**
39+
**Install Playwright:**
40+
41+
The bundle includes a helper to set up the Playwright environment and download browsers:
4042

4143
```bash
42-
npx playwright install
43-
# Or install specific browser
44-
npx playwright install chromium
44+
vendor/bin/playwright-install
45+
vendor/bin/playwright-install --browsers
4546
```
4647

4748
### Bundle Setup
@@ -378,24 +379,24 @@ jobs:
378379
PLAYWRIGHT_HEADLESS: 'true'
379380
```
380381

381-
## Comparison with WebTestCase
382+
## Comparison with other tools
383+
384+
| Feature | WebTestCase | Panther | PlaywrightTestCase |
385+
|---------|-------------|---------|-------------------|
386+
| Real browser | No | Yes | Yes |
387+
| JavaScript execution | No | Yes | Yes |
388+
| In-process requests | Yes | No | Yes |
389+
| No external web server | Yes | No | Yes |
390+
| CSS rendering | No | Yes | Yes |
391+
| AJAX & async requests | Limited | Full support | Full support |
392+
| Screenshots & videos | No | Yes | Yes |
393+
| Performance | Fast | Slow | Fast (optimized) |
382394

383-
| Feature | WebTestCase | PlaywrightTestCase |
384-
|---------|-------------|-------------------|
385-
| Real browser | No | Yes |
386-
| JavaScript execution | No | Yes |
387-
| CSS rendering & animations | No | Yes |
388-
| AJAX & async requests | Limited | Full support |
389-
| Multiple browser tabs | No | Yes |
390-
| File downloads | Limited | Yes |
391-
| Screenshots & videos | No | Yes |
392-
| Symfony kernel integration | Yes | Yes |
393-
| Request/response inspection | Yes | Yes |
394-
| Test speed | Fast | Slower |
395+
**Use WebTestCase for:** API testing, simple form submissions, fast unit-like functional tests.
395396

396-
**Use WebTestCase for:** API testing, simple form submissions, fast test suites
397+
**Use Panther for:** Standard Selenium-style E2E testing when you need a real web server.
397398

398-
**Use PlaywrightTestCase for:** Complex UIs, JavaScript-heavy apps, visual regression testing
399+
**Use PlaywrightTestCase for:** Complex UIs, JavaScript-heavy apps, and high-performance E2E testing with full kernel access.
399400

400401
## Known Limitations
401402

docs/COOKIE_IMPLEMENTATION.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,19 @@ Retrieves a cookie value from the browser context.
8383

8484
#### `clearCookie(string $name, ?string $domain = null, string $path = '/'): void`
8585

86-
Removes a specific cookie from the browser context.
86+
Removes a specific cookie from the browser context by setting its expiration to the past.
8787

8888
**Implementation:**
8989
```php
9090
public function clearCookie(string $name, ?string $domain = null, string $path = '/'): void
9191
{
92-
if (null === $domain) {
93-
$domain = parse_url($this->getBaseUrl(), PHP_URL_HOST) ?? 'localhost';
94-
}
95-
96-
$this->browser->getContext()?->deleteCookie($name, $domain, $path);
92+
$options = [
93+
'domain' => $domain ?? parse_url($this->getBaseUrl(), PHP_URL_HOST) ?? 'localhost',
94+
'path' => $path,
95+
'expires' => 0, // Force expiration
96+
];
97+
98+
$this->setCookie($name, '', $options);
9799
}
98100
```
99101

0 commit comments

Comments
 (0)