Skip to content

Commit f111794

Browse files
committed
feat: 테스트에서 가용한 포트를 직접 찾도록 구현
- portfinder 라이브러리 추가 - 가용한 포트를 찾아 listen하고, 환경변수로 지정하는 listenAppAndSetPortEnv 메서드 추가 - 테스트에서 사용할 포트를 환경변수로 받도록 변경
1 parent b693606 commit f111794

14 files changed

+82
-21
lines changed

backend/package-lock.json

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

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"eslint-config-prettier": "^9.0.0",
5656
"eslint-plugin-prettier": "^5.0.0",
5757
"jest": "^29.5.0",
58+
"portfinder": "^1.0.32",
5859
"prettier": "^3.0.0",
5960
"socket.io-client": "^4.7.5",
6061
"source-map-support": "^0.5.21",

backend/test/project/join-project.e2e-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createMember,
66
createProject,
77
getProjectLinkId,
8+
listenAppAndSetPortEnv,
89
memberFixture,
910
memberFixture2,
1011
projectPayload,
@@ -14,7 +15,7 @@ describe('Join Project', () => {
1415
beforeEach(async () => {
1516
await app.close();
1617
await appInit();
17-
await app.listen(3000);
18+
await listenAppAndSetPortEnv(app);
1819
});
1920

2021
it('should return 201', async () => {

backend/test/project/ws-backlog-page/ws-epic.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LexoRank } from 'lexorank';
22
import { resolve } from 'path';
33
import { Socket } from 'socket.io-client';
4-
import { app, appInit } from 'test/setup';
4+
import { app, appInit, listenAppAndSetPortEnv } from 'test/setup';
55
import {
66
getMemberJoinedLandingPage,
77
getTwoMemberJoinedLandingPage,
@@ -11,7 +11,7 @@ describe('WS epic', () => {
1111
beforeEach(async () => {
1212
await app.close();
1313
await appInit();
14-
await app.listen(3000);
14+
await listenAppAndSetPortEnv(app);
1515
});
1616

1717
describe('epic create', () => {

backend/test/project/ws-backlog-page/ws-init-backlog.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { LexoRank } from 'lexorank';
22
import { Socket } from 'socket.io-client';
3-
import { app, appInit } from 'test/setup';
3+
import { app, appInit, listenAppAndSetPortEnv } from 'test/setup';
44
import { getTwoMemberJoinedLandingPage } from '../ws-common';
55

66
describe('WS epic', () => {
77
beforeEach(async () => {
88
await app.close();
99
await appInit();
10-
await app.listen(3000);
10+
await listenAppAndSetPortEnv(app);
1111
});
1212

1313
describe('backlog init', () => {

backend/test/project/ws-backlog-page/ws-story.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LexoRank } from 'lexorank';
22
import { Socket } from 'socket.io-client';
3-
import { app, appInit } from 'test/setup';
3+
import { app, appInit, listenAppAndSetPortEnv } from 'test/setup';
44
import {
55
getMemberJoinedLandingPage,
66
getTwoMemberJoinedLandingPage,
@@ -10,7 +10,7 @@ describe('WS story', () => {
1010
beforeEach(async () => {
1111
await app.close();
1212
await appInit();
13-
await app.listen(3000);
13+
await listenAppAndSetPortEnv(app);
1414
});
1515

1616
describe('story create', () => {

backend/test/project/ws-backlog-page/ws-task.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LexoRank } from 'lexorank';
22
import { Socket } from 'socket.io-client';
3-
import { app, appInit } from 'test/setup';
3+
import { app, appInit, listenAppAndSetPortEnv } from 'test/setup';
44
import {
55
getMemberJoinedLandingPage,
66
getTwoMemberJoinedLandingPage,
@@ -10,7 +10,7 @@ describe('WS task', () => {
1010
beforeEach(async () => {
1111
await app.close();
1212
await appInit();
13-
await app.listen(3000);
13+
await listenAppAndSetPortEnv(app);
1414
});
1515

1616
describe('task create', () => {

backend/test/project/ws-landing-page/ws-connection.e2e-spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import {
55
createMember,
66
createProject,
77
githubApiService,
8+
listenAppAndSetPortEnv,
89
memberFixture,
910
memberFixture2,
1011
projectPayload,
1112
} from 'test/setup';
1213
import { io } from 'socket.io-client';
1314

1415
describe('WS landing', () => {
15-
const serverUrl = 'http://localhost:3000/project';
16+
let serverUrl;
1617
let socket;
1718

1819
beforeEach(async () => {
1920
await app.close();
2021
await appInit();
21-
await app.listen(3000);
22+
await listenAppAndSetPortEnv(app);
23+
serverUrl = `http://localhost:${process.env.PORT}/project`;
2224
});
2325

2426
afterEach(async () => {

backend/test/project/ws-landing-page/ws-join-project.e2e-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getProjectLinkId,
1010
memberFixture2,
1111
joinProject,
12+
listenAppAndSetPortEnv,
1213
} from 'test/setup';
1314
import {
1415
emitJoinLanding,
@@ -23,7 +24,7 @@ describe('WS join project', () => {
2324
beforeEach(async () => {
2425
await app.close();
2526
await appInit();
26-
await app.listen(3000);
27+
await listenAppAndSetPortEnv(app);
2728
});
2829

2930
it('should return joined member', async () => {

backend/test/project/ws-landing-page/ws-link.e2e-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createProject,
77
getProjectLinkId,
88
joinProject,
9+
listenAppAndSetPortEnv,
910
memberFixture,
1011
memberFixture2,
1112
projectPayload,
@@ -23,7 +24,7 @@ describe('WS link', () => {
2324
beforeEach(async () => {
2425
await app.close();
2526
await appInit();
26-
await app.listen(3000);
27+
await listenAppAndSetPortEnv(app);
2728
});
2829
describe('link create', () => {
2930
it('should return created link data when received create link request', async () => {

0 commit comments

Comments
 (0)