Skip to content

Commit

Permalink
chore: e2e local development (#564)
Browse files Browse the repository at this point in the history
# Motivation

It's easier to develop E2E tests while being able to run those against a
local server and not in headless mode. This PR provides such a setup.

# Changes

- Add new `npm run e2e:dev` command line
- If dev mode, then use dev server and no headles in the Playwright
config
  • Loading branch information
peterpeterparker authored Jan 21, 2025
1 parent 5f1e908 commit 40efecf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"e2e": "npm run download:samples && playwright test",
"e2e:ci": "npm run download:samples && playwright test --reporter=html",
"e2e:snapshots": "npm run download:samples && npx playwright test --update-snapshots --reporter=list",
"e2e:report": "npx playwright show-report"
"e2e:report": "npx playwright show-report",
"e2e:dev": "NODE_ENV=development playwright test"
},
"sideEffects": [
"**/*.css"
Expand Down
18 changes: 14 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import type { PlaywrightTestConfig } from "@playwright/test";
import { devices } from "@playwright/test";

const DEV = (process.env.NODE_ENV ?? "production") === "development";

const webServer = DEV
? {
command: "npm run dev",
reuseExistingServer: true,
port: 5173,
}
: {
command: "npm run staging && npm run preview",
port: 4173,
};

const config: PlaywrightTestConfig = {
webServer: {
command: "npm run staging && npm run preview",
port: 4173,
},
webServer,
testDir: "e2e",
testMatch: ["**/*.e2e.ts"],
use: {
Expand Down

0 comments on commit 40efecf

Please sign in to comment.