Skip to content

Commit

Permalink
test: create storage state file on start
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Dec 19, 2024
1 parent 114a5e9 commit 2da8379
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { existsSync, writeFileSync } from "node:fs";

dotenv.config({ path: ".env.test.local" });

export const STORAGE_STATE = fileURLToPath(
new URL("./tests/.storage-state.json", import.meta.url),
);
if (!existsSync(STORAGE_STATE))
writeFileSync(STORAGE_STATE, JSON.stringify({}));

// https://playwright.dev/docs/test-configuration
export default defineConfig({
Expand All @@ -20,19 +23,22 @@ export default defineConfig({
reporter: "html",
use: {
trace: "on-first-retry",
storageState: STORAGE_STATE,
},
projects: [
{
name: "Setup",
testMatch: "*.setup.*",
use: {
storageState: STORAGE_STATE,
},
},
{
name: "App Router",
dependencies: ["Setup"],
use: {
...devices["Desktop Chrome"],
baseURL: "http://localhost:4321",
storageState: STORAGE_STATE,
},
},
{
Expand All @@ -41,6 +47,7 @@ export default defineConfig({
use: {
...devices["Desktop Chrome"],
baseURL: "http://localhost:4322",
storageState: STORAGE_STATE,
},
},
],
Expand Down

0 comments on commit 2da8379

Please sign in to comment.