Skip to content

Commit

Permalink
Update playwright.config: set server URL based on env (aeharding#1393)
Browse files Browse the repository at this point in the history
* When `process.env.CI` is true (in a GitHub action, for instance),
  tests run on the production build; otherwise, they run on the dev
  server.
  • Loading branch information
aashu16 authored Apr 5, 2024
1 parent dfbe1f7 commit 0c04cd2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, devices } from "@playwright/test";

const serverURL = "http://localhost:" + (process.env.CI ? "4173" : "5173");

export default defineConfig({
testDir: "./e2e",
fullyParallel: true,
Expand All @@ -8,7 +10,7 @@ export default defineConfig({
workers: process.env.CI ? 1 : undefined,
reporter: "list",
use: {
baseURL: "http://localhost:4173",
baseURL: serverURL,

trace: "on-first-retry",
},
Expand Down Expand Up @@ -37,8 +39,8 @@ export default defineConfig({
],

webServer: {
command: "pnpm preview",
url: "http://localhost:4173",
command: process.env.CI ? "pnpm preview" : "pnpm dev",
url: serverURL,
reuseExistingServer: !process.env.CI,
},
});

0 comments on commit 0c04cd2

Please sign in to comment.