Skip to content

Commit

Permalink
Merge pull request #167 from jbrunton/improve-e2e-setup
Browse files Browse the repository at this point in the history
chore: e2e setup script
  • Loading branch information
jbrunton authored Aug 31, 2024
2 parents a0023c9 + ae38acb commit 4eaaaf5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ pnpm dev
```

The web client will then be running locally at http://localhost:5173/.

To configure environment variables for the Playwright e2e tests:

```console
pnpm test:e2e:setup
```
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",
"test:e2e: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();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test:int": "turbo test:int",
"test:e2e": "pnpm run --filter e2e test:e2e",
"test:e2e:ui": "pnpm run --filter e2e test:e2e:ui",
"test:e2e:setup": "pnpm run --filter e2e test:e2e:setup",
"build": "turbo build",
"dev": "turbo dev",
"dev:setup": "turbo dev:setup",
Expand Down
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 4eaaaf5

Please sign in to comment.