Skip to content

Commit

Permalink
test: 기본적인 e2e 환경 선언
Browse files Browse the repository at this point in the history
- 유닛 테스트에서 SSH 접속하는 그림이 좀 안 좋은 거 같아서 e2e로 해볼까 시도 중입니다.

[#149]
  • Loading branch information
flydog98 authored and LuizyHub committed Nov 30, 2023
1 parent fc69af8 commit 43ec32d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
],
"coverageDirectory": "../coverage",
"testEnvironment": "node",
"testTimeout": 20000
"testTimeout": 20000,
"globals": {
"NODE_ENV": "test"
}
}
}
31 changes: 23 additions & 8 deletions packages/backend/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
import request from 'supertest';
import { AppModule } from '../src/app.module';

describe('AppController (e2e)', () => {
describe('QuizWizardController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
Expand All @@ -15,10 +15,25 @@ describe('AppController (e2e)', () => {
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
it('should solve quiz for git init command', async () => {
// 명령 실행
await request(app.getHttpServer())
.post('/api/v1/quizzes/1/command')
.send({
mode: 'command',
message: 'git init',
})
.expect(200);

// 퀴즈 제출 및 검증
const response = await request(app.getHttpServer())
.post('/api/v1/quizzes/1/submit')
.expect(200);

expect(response.body).toHaveProperty('solved', true);
});

afterEach(async () => {
await app.close();
});
});

0 comments on commit 43ec32d

Please sign in to comment.