{"id":36970097,"url":"https://github.com/leeovery/laravel-playwright","last_synced_at":"2026-01-13T21:44:22.624Z","repository":{"id":65125454,"uuid":"582377139","full_name":"leeovery/laravel-playwright","owner":"leeovery","description":"Backend stuff for Playwright e2e tests","archived":false,"fork":false,"pushed_at":"2025-11-21T16:47:53.000Z","size":23322,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T01:43:45.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leeovery.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-26T16:24:33.000Z","updated_at":"2025-11-21T16:47:00.000Z","dependencies_parsed_at":"2023-02-15T15:46:35.605Z","dependency_job_id":null,"html_url":"https://github.com/leeovery/laravel-playwright","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/leeovery/laravel-playwright","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeovery%2Flaravel-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeovery%2Flaravel-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeovery%2Flaravel-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeovery%2Flaravel-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leeovery","download_url":"https://codeload.github.com/leeovery/laravel-playwright/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeovery%2Flaravel-playwright/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28401077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T21:44:21.814Z","updated_at":"2026-01-13T21:44:22.619Z","avatar_url":"https://github.com/leeovery.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Playwright\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/leeovery/laravel-playwright.svg?style=flat-square)](https://packagist.org/packages/leeovery/laravel-playwright)\n[![Total Downloads](https://img.shields.io/packagist/dt/leeovery/laravel-playwright.svg?style=flat-square)](https://packagist.org/packages/leeovery/laravel-playwright)\n![GitHub Actions](https://github.com/leeovery/laravel-playwright/actions/workflows/main.yml/badge.svg)\n\nBackend utilities for Playwright e2e tests. Provides HTTP endpoints and commands to control your Laravel application during testing - manage databases, factories, authentication, migrations, and environment configuration from your Playwright tests.\n\n## Requirements\n\n- PHP 8.3+\n- Laravel 11+\n\n## Installation\n\n```bash\ncomposer require leeovery/laravel-playwright --dev\n```\n\nPublish config and register service provider:\n\n```bash\nphp artisan playwright:install\n```\n\n## Configuration\n\nThe package config (`config/playwright.php`) includes:\n\n- **Environments**: Control which environments expose the endpoints (default: `local,testing,playwright`)\n- **Route prefix**: Customize the endpoint URL prefix (default: `__playwright__`)\n- **Middleware**: Set middleware for routes (default: `web`)\n- **Environment files**: Configure `.playwright.env` file handling\n- **Factory settings**: Map model aliases and configure factory behaviors\n\nCreate a `.playwright.env` file for test-specific environment variables.\n\n## Features\n\n### HTTP Endpoints\n\nAll endpoints are prefixed with `__playwright__` (configurable) and protected by environment checks:\n\n#### Database Management\n\n- `POST /create-database` - Create test database\n- `POST /drop-database` - Drop test database\n- `POST /migrate` - Run migrations (supports `?fresh=1\u0026seed=1`)\n- `POST /truncate` - Truncate specific tables\n\n#### Factory \u0026 Authentication\n\n- `POST /factory` - Create model instances via factories\n- `POST /login` - Authenticate user (create or find existing)\n- `POST /logout` - End session\n- `POST /user` - Get current authenticated user\n\n#### Utilities\n\n- `POST /artisan` - Execute artisan commands\n- `POST /routes` - Get application route list\n- `GET /csrf` - Get CSRF token\n- `POST /env-setup` - Swap to `.playwright.env`\n- `POST /env-teardown` - Restore original `.env`\n\n### Artisan Commands\n\n```bash\n# Setup/teardown test environment\nphp artisan playwright:env-setup\nphp artisan playwright:env-teardown\n\n# Database operations\nphp artisan db:create --database=playwright_test\nphp artisan db:drop --database=playwright_test\n```\n\n## Usage Example\n\nFrom Playwright tests, interact with Laravel via HTTP:\n\n```javascript\n// Setup environment\nawait request.post(\"http://localhost/__playwright__/env-setup\");\n\n// Run migrations\nawait request.post(\"http://localhost/__playwright__/migrate\", {\n  data: { fresh: true, seed: true },\n});\n\n// Create and login user\nconst user = await request.post(\"http://localhost/__playwright__/factory\", {\n  data: {\n    model: \"User\",\n    state: [\"verified\"],\n    attributes: { email: \"test@example.com\" },\n  },\n});\n\nawait request.post(\"http://localhost/__playwright__/login\", {\n  data: { attributes: { email: \"test@example.com\" } },\n});\n\n// Teardown\nawait request.post(\"http://localhost/__playwright__/env-teardown\");\n```\n\n### Factory State Parameters\n\nPass complex state parameters to factories:\n\n```javascript\n// Fetch model and pass to state method\ndata: {\n  state: [\n    { createdBy: [\"model.User:100\"] }, // Fetch User with id=100\n  ];\n}\n\n// Use param aliases (configure in config/playwright.php)\ndata: {\n  state: [{ endsAt: [\"Carbon(2023-12-25 23:59:59)\"] }];\n}\n```\n\nRegister param aliases in your service provider:\n\n```php\nuse Leeovery\\LaravelPlaywright\\Playwright;\n\nPlaywright::paramAlias('Carbon', fn($date) =\u003e new Carbon($date));\n```\n\n## Security\n\n**Important**: This package exposes powerful endpoints that can manipulate your application. Only enable in non-production environments. The package includes middleware that blocks requests outside configured environments.\n\nIf you discover security issues, email me@leeovery.com.\n\n## Testing\n\n```bash\ncomposer test\ncomposer test-coverage\n```\n\n## Development\n\n```bash\n# Format code with Pint\ncomposer pint\n\n# Refactor code with Rector\ncomposer rector\n```\n\n## Credits\n\n- [Lee Overy](https://github.com/leeovery)\n- [All Contributors](../../contributors)\n\n## License\n\nMIT License. See [License File](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeovery%2Flaravel-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleeovery%2Flaravel-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeovery%2Flaravel-playwright/lists"}