Repository navigation
feat: run e2e on its own environment with laravel-playwright v2 #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| /// <reference types="node" /> | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
| import type { LaravelOptions } from '@saucebase/laravel-playwright'; | ||
| import 'dotenv/config'; | ||
| import { laravelServer, type LaravelOptions } from '@saucebase/laravel-playwright'; | ||
| import { config } from 'dotenv'; | ||
| import { saucebaseProjects } from './vendor/saucebase/core/resources/js/modules.ts'; | ||
|
|
||
| const BASE_URL = process.env.APP_URL ?? 'http://localhost'; | ||
| // The suite runs on its own server and database, never the app's (.env.e2e). | ||
| // Loading .env here instead would hand that server your database. | ||
| const e2e = config({ path: '.env.e2e', quiet: true }).parsed ?? {}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔎 Supported by static analysis
Stop inherited database variables from reaching the E2E server.
Reject conflicting database variables before the server starts, or give
|
||
| // From the file, not process.env: an APP_URL exported for the dev app would win there, | ||
| // and the suite would test it while laravelServer() serves .env.e2e's. | ||
| const BASE_URL = e2e.APP_URL ?? 'http://localhost:8100'; | ||
|
|
||
| async function createConfig() { | ||
| // database.setup, every module's setups and projects, per device, in order. | ||
|
|
@@ -56,12 +61,15 @@ async function createConfig() { | |
|
|
||
| /** Laravel Playwright integration */ | ||
| laravelBaseUrl: `${BASE_URL}/playwright`, | ||
| laravelSecret: process.env.PLAYWRIGHT_SECRET, | ||
| laravelSecret: e2e.PLAYWRIGHT_SECRET, | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects, | ||
|
|
||
| /* Migrates .env.e2e's database, then serves it on APP_URL's port. */ | ||
| webServer: laravelServer(), | ||
|
|
||
| /** | ||
| * Tests run against built assets, the way CI does. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Supported by static analysis
Script executed:
Repository: saucebase-dev/saucebase
Length of output: 41522
Script executed:
Repository: saucebase-dev/saucebase
Length of output: 22831
Web query:
saucebase laravel-playwright v2.1.0 "playwright:env" sourceResult:
Script executed:
Repository: saucebase-dev/saucebase
Length of output: 16217
Limit the isolation claim to the database.
playwright:envisolates the database, cache, queue, mail, and session drivers, but it leaves the local filesystem shared with the app. File sessions and local-disk writes can therefore modify the app checkout.Suggested documentation fix