Skip to content

Commit

Permalink
Run dotenv in E2E codebase itself
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Jun 18, 2024
1 parent 5366ba7 commit b79bee6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 64 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/e2e-api-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

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

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

- name: Build stack-backend
Expand All @@ -51,6 +51,11 @@ jobs:
- name: Initialize database
run: pnpm run prisma -- migrate reset --force

- name: Start stack-backend in background
run: pnpm run start:backend &
- name: Wait for stack-backend to start
run: npx [email protected] http://localhost:8102

- name: Start stack-dashboard in background
run: pnpm run start:dashboard &
- name: Wait for stack-dashboard to start
Expand Down
6 changes: 3 additions & 3 deletions apps/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": true,
"type": "module",
"scripts": {
"test:watch": "dotenv -c development -- vitest watch",
"test": "dotenv -c development -- vitest run",
"test:watch": "vitest watch",
"test": "vitest run",
"lint": "eslint --ext .tsx,.ts .",
"clean": "rimraf dist && rimraf node_modules"
},
"dependencies": {},
"devDependencies": {
"dotenv-cli": "7.4.1"
"dotenv": "^16.4.5"
}
}
5 changes: 0 additions & 5 deletions apps/e2e/tests/api/internal-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,30 @@ async function signInWithEmailPassword(email: string, password: string) {
describe("Various internal project tests", () => {
test("Main Page", async () => {
const response = await request(BASE_URL).get("/");
console.log(response);
expect(response.status).toBe(307);
});

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

test("Credential sign up", async () => {
const { response } = await signUpWithEmailPassword();
console.log(response);
expect(response.status).toBe(200);
});

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

expect(response.status).toBe(200);
});

test("No current user without authentication", async () => {
const response = await request(BASE_URL).get("/api/v1/current-user").set(AUTH_HEADER);
console.log(response);
expect(response.status).toBe(200);
expect(response.body).toBe(null);
});
Expand Down
14 changes: 14 additions & 0 deletions apps/e2e/tests/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import dotenv from "dotenv";

export default function globalSetup() {
dotenv.config({
path: [
".env.development.local",
".env.local",
".env.development",
".env",
],
});

return () => {};
}
4 changes: 2 additions & 2 deletions apps/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"rootDir": "tests",
"declaration": true,
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"esModuleInterop": true,
"noErrorTruncation": true,
"strict": true,
Expand Down
3 changes: 2 additions & 1 deletion apps/e2e/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'

export default defineConfig({
plugins: [react()],
test: {
environment: 'node',
testTimeout: 20_000,
globalSetup: './tests/global-setup.ts',
},
})
57 changes: 6 additions & 51 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b79bee6

Please sign in to comment.