Skip to content

Commit

Permalink
chore: e2e setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrunton committed Aug 31, 2024
1 parent bfb1e7e commit 4f6a581
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions chat-demo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
},
{
"path": "client"
},
{
"path": "e2e"
}
],
"settings": {}
Expand Down
3 changes: 2 additions & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"packageManager": "[email protected]",
"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": "",
Expand Down
26 changes: 26 additions & 0 deletions e2e/scripts/setup-env.js
Original file line number Diff line number Diff line change
@@ -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 = [
"[email protected]",
`USER1_PASSWORD=${user1Password}`,
"[email protected]",
`USER2_PASSWORD=${user2Password}`,
"",
].join("\n");

fs.writeFileSync(".env", content, { encoding: "utf8" });

console.info(".env file created for e2e tests");
};

setupEnvFile();
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"persistent": true
},
"dev:setup": {
"cache": false,
"env": ["AUTH0_TEST_USER1_PASSWORD", "AUTH0_TEST_USER2_PASSWORD"]
},
"dev:teardown": {
"cache": false
}
}
Expand Down

0 comments on commit 4f6a581

Please sign in to comment.