diff --git a/chat-demo.code-workspace b/chat-demo.code-workspace index 6b0ee1f6..9d7021f6 100644 --- a/chat-demo.code-workspace +++ b/chat-demo.code-workspace @@ -5,6 +5,9 @@ }, { "path": "client" + }, + { + "path": "e2e" } ], "settings": {} diff --git a/e2e/package.json b/e2e/package.json index 32311549..9fec6562 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -6,7 +6,8 @@ "packageManager": "pnpm@9.8.0", "scripts": { "test:e2e": "playwright test", - "test:e2e:ui": "playwright test --ui" + "test:e2e:ui": "playwright test --ui", + "dev:setup": "node scripts/setup-env" }, "keywords": [], "author": "", diff --git a/e2e/scripts/setup-env.js b/e2e/scripts/setup-env.js new file mode 100644 index 00000000..b918c9ce --- /dev/null +++ b/e2e/scripts/setup-env.js @@ -0,0 +1,26 @@ +const fs = require("fs"); + +const setupEnvFile = () => { + const user1Password = process.env.AUTH0_TEST_USER1_PASSWORD; + const user2Password = process.env.AUTH0_TEST_USER2_PASSWORD; + + if (!user1Password || !user2Password) { + throw new Error( + "Script requires AUTH0_TEST_USER1_PASSWORD and AUTH0_TEST_USER2_PASSWORD env vars" + ); + } + + const content = [ + "USER1_EMAIL=test.user.1@example.com", + `USER1_PASSWORD=${user1Password}`, + "USER2_EMAIL=test.user.2@example.com", + `USER2_PASSWORD=${user2Password}`, + "", + ].join("\n"); + + fs.writeFileSync(".env", content, { encoding: "utf8" }); + + console.info(".env file created for e2e tests"); +}; + +setupEnvFile(); diff --git a/turbo.json b/turbo.json index bb8af273..227408d9 100644 --- a/turbo.json +++ b/turbo.json @@ -19,6 +19,10 @@ "persistent": true }, "dev:setup": { + "cache": false, + "env": ["AUTH0_TEST_USER1_PASSWORD", "AUTH0_TEST_USER2_PASSWORD"] + }, + "dev:teardown": { "cache": false } }