Skip to content

Commit 6f65919

Browse files
committed
fix: set test env defaults for S3, Redis, and Hasura in e2e tests
S3Service constructor crashes with InvalidEndpointError when DEMOS_DOMAIN is undefined, preventing test module compilation. Add setupFiles with test env defaults and guard afterAll teardown.
1 parent 1594a1e commit 6f65919

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

test/app.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe("AppController (e2e)", () => {
1616
});
1717

1818
afterAll(async () => {
19-
await app.close();
19+
if (app) await app.close();
2020
});
2121

2222
it("should boot the application", () => {

test/auth.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe("Auth Guards (e2e)", () => {
1616
});
1717

1818
afterAll(async () => {
19-
await app.close();
19+
if (app) await app.close();
2020
});
2121

2222
describe("unauthenticated requests", () => {

test/jest-e2e.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"^.+\\.(t|j)s$": "ts-jest"
88
},
99
"transformIgnorePatterns": [],
10+
"setupFiles": ["./test-env.ts"],
1011
"globalSetup": "./setup.ts",
1112
"globalTeardown": "./teardown.ts",
1213
"moduleNameMapper": {

test/matches.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Matches (e2e)", () => {
2424
});
2525

2626
afterAll(async () => {
27-
await app.close();
27+
if (app) await app.close();
2828
});
2929

3030
describe("GET /matches/current-match/:serverId", () => {

test/test-env.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test environment defaults — loaded via jest setupFiles before each test worker.
2+
// Values are only set if not already present, so CI or local .env can override.
3+
4+
process.env.DEMOS_DOMAIN = process.env.DEMOS_DOMAIN || "localhost";
5+
process.env.S3_ACCESS_KEY = process.env.S3_ACCESS_KEY || "test-key";
6+
process.env.S3_SECRET = process.env.S3_SECRET || "test-secret";
7+
process.env.S3_BUCKET = process.env.S3_BUCKET || "test-bucket";
8+
process.env.S3_ENDPOINT = process.env.S3_ENDPOINT || "localhost";
9+
process.env.S3_PORT = process.env.S3_PORT || "9000";
10+
11+
process.env.REDIS_HOST = process.env.REDIS_HOST || "localhost";
12+
process.env.REDIS_SERVICE_PORT = process.env.REDIS_SERVICE_PORT || "6380";
13+
14+
process.env.HASURA_GRAPHQL_ENDPOINT =
15+
process.env.HASURA_GRAPHQL_ENDPOINT || "http://localhost:8080";
16+
process.env.HASURA_GRAPHQL_ADMIN_SECRET =
17+
process.env.HASURA_GRAPHQL_ADMIN_SECRET || "test-secret";

0 commit comments

Comments
 (0)