Skip to content

Commit b79bee6

Browse files
committed
Run dotenv in E2E codebase itself
1 parent 5366ba7 commit b79bee6

File tree

7 files changed

+34
-64
lines changed

7 files changed

+34
-64
lines changed

.github/workflows/e2e-api-tests.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
- name: Install dependencies
3535
run: pnpm install --frozen-lockfile
3636

37-
- name: Create .env.local file for stack-backend
37+
- name: Create .env.production.local file for stack-backend
3838
run: cp apps/backend/.env.development apps/backend/.env.production.local
3939

40-
- name: Create .env.local file for stack-dashboard
40+
- name: Create .env.production.local file for stack-dashboard
4141
run: cp apps/dashboard/.env.development apps/dashboard/.env.production.local
4242

4343
- name: Build stack-backend
@@ -51,6 +51,11 @@ jobs:
5151
- name: Initialize database
5252
run: pnpm run prisma -- migrate reset --force
5353

54+
- name: Start stack-backend in background
55+
run: pnpm run start:backend &
56+
- name: Wait for stack-backend to start
57+
run: npx wait-on@7.2.0 http://localhost:8102
58+
5459
- name: Start stack-dashboard in background
5560
run: pnpm run start:dashboard &
5661
- name: Wait for stack-dashboard to start

apps/e2e/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"test:watch": "dotenv -c development -- vitest watch",
8-
"test": "dotenv -c development -- vitest run",
7+
"test:watch": "vitest watch",
8+
"test": "vitest run",
99
"lint": "eslint --ext .tsx,.ts .",
1010
"clean": "rimraf dist && rimraf node_modules"
1111
},
1212
"dependencies": {},
1313
"devDependencies": {
14-
"dotenv-cli": "7.4.1"
14+
"dotenv": "^16.4.5"
1515
}
1616
}

apps/e2e/tests/api/internal-project.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,30 @@ async function signInWithEmailPassword(email: string, password: string) {
4040
describe("Various internal project tests", () => {
4141
test("Main Page", async () => {
4242
const response = await request(BASE_URL).get("/");
43-
console.log(response);
4443
expect(response.status).toBe(307);
4544
});
4645

4746
test("API root (no authentication)", async () => {
4847
const response = await request(BASE_URL).get("/api/v1");
49-
console.log(response);
5048
expect(response.status).toBe(200);
5149
expect(response.text).contains("Stack API");
5250
expect(response.text).contains("Authentication: None");
5351
});
5452

5553
test("Credential sign up", async () => {
5654
const { response } = await signUpWithEmailPassword();
57-
console.log(response);
5855
expect(response.status).toBe(200);
5956
});
6057

6158
test("Credential sign in", async () => {
6259
const { email, password } = await signUpWithEmailPassword();
6360
const { response } = await signInWithEmailPassword(email, password);
64-
console.log(response);
6561

6662
expect(response.status).toBe(200);
6763
});
6864

6965
test("No current user without authentication", async () => {
7066
const response = await request(BASE_URL).get("/api/v1/current-user").set(AUTH_HEADER);
71-
console.log(response);
7267
expect(response.status).toBe(200);
7368
expect(response.body).toBe(null);
7469
});

apps/e2e/tests/global-setup.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import dotenv from "dotenv";
2+
3+
export default function globalSetup() {
4+
dotenv.config({
5+
path: [
6+
".env.development.local",
7+
".env.local",
8+
".env.development",
9+
".env",
10+
],
11+
});
12+
13+
return () => {};
14+
}

apps/e2e/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"rootDir": "tests",
66
"declaration": true,
77
"target": "ESNext",
8-
"module": "NodeNext",
9-
"moduleResolution": "NodeNext",
8+
"module": "ESNext",
9+
"moduleResolution": "Bundler",
1010
"esModuleInterop": true,
1111
"noErrorTruncation": true,
1212
"strict": true,

apps/e2e/vitest.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { defineConfig } from 'vitest/config'
22
import react from '@vitejs/plugin-react'
3-
3+
44
export default defineConfig({
55
plugins: [react()],
66
test: {
77
environment: 'node',
88
testTimeout: 20_000,
9+
globalSetup: './tests/global-setup.ts',
910
},
1011
})

pnpm-lock.yaml

Lines changed: 6 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)