묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
배열
배열 안에 자료형이 여러가지 된 숫자, 문자열 , 볼린 값들을 저장이 가능합니까?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
노션 링크 어디에 있나요?
아무리 찾아봐도 링크 주소를 찾지 못해서 링크 주소 올려주시면 감사드립니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
query 없이 mutation 만작성하면 오류가 난다?
안녕하세요~복습중 이상한 현상이 발생하여 질문드립니다~답변 주시면 감사하겠습니다~ 질문1.resolver 부분에서 boards() 부분의 주석 부분을 해제해야, 맨아래 3번 오류가 발생하지 않고, 정상 작동 합니다.Query 없이 Mutation 만작성하면 오류가 발생하는걸까요? 아래 코드와 같이 query 부분을 주석 처리 하면 왜 오류가 나는 걸까요? 질문2.에러가 내가 작성한 파일의 어떤부분이 잘못됐다고,알려주는건 없는 걸까요?아래 에러 코드를 보면 내가 작성한 코드가 아닌작성하지도 않은 설치 파일같은데서 error 정보가 나오는데, 저기를 열어봐야 할까요? GraphQLError: Query root type must be provided. at SchemaValidationContext.reportError (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\type\validate.js:73:7) 1.resolverimport { Args, Mutation, Resolver } from '@nestjs/graphql'; import { BoardsService } from './boards.service'; import { CreateBoardInput } from './dto/create-board.input'; import { Board } from './entities/board.entity'; @Resolver() export class BoardsResolver { constructor(private readonly boardsService: BoardsService) {} // @Query(() => String) // boards(): string { // return this.boardsService.boards(); // } @Mutation(() => Board) createBoard( @Args('createBoardInput') createBoardInput: CreateBoardInput, // ): Promise<Board> { return this.boardsService.create({ createBoardInput }); } } 2.serviceimport { Injectable } from '@nestjs/common'; import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; import { IBoardsServiceCreate } from './interfaces/boards-service.interface'; import { Board } from './entities/board.entity'; @Injectable() export class BoardsService { constructor( @InjectRepository(Board) private readonly boardsRepository: Repository<Board>, // ) {} // boards() { // return 'boards'; // } create({ createBoardInput }: IBoardsServiceCreate): Promise<Board> { return this.boardsRepository.save({ ...createBoardInput }); } } 3.error[ GraphQLError: Query root type must be provided. at SchemaValidationContext.reportError (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\type\validate.js:73:7) at validateRootTypes (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\type\validate.js:89:13) at validateSchema (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\type\validate.js:41:3) at graphqlImpl (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\graphql.js:60:63) at C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\graphql.js:23:43 at new Promise (<anonymous>) at graphql (C:\study\00-codecamp-backend\연습장\memo01\node_modules\graphql\graphql.js:23:10) at GraphQLSchemaFactory.create (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\schema-builder\graphql-schema.factory.js:50:65) at GraphQLSchemaBuilder.generateSchema (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql-schema.builder.js:35:52) at GraphQLSchemaBuilder.build (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql-schema.builder.js:22:31) { path: undefined, locations: undefined, extensions: [Object: null prototype] {} } ] C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\schema-builder\graphql-schema.factory.js:56 throw new schema_generation_error_1.SchemaGenerationError(errors); ^ Error: Schema generation error (code-first approach) at GraphQLSchemaFactory.create (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\schema-builder\graphql-schema.factory.js:56:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at GraphQLSchemaBuilder.generateSchema (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql-schema.builder.js:35:24) at GraphQLSchemaBuilder.build (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql-schema.builder.js:22:20) at GraphQLFactory.generateSchema (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql.factory.js:27:41) at GraphQLModule.onModuleInit (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\graphql\dist\graphql.module.js:109:27) at callModuleInitHook (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\core\hooks\on-module-init.hook.js:51:9) at NestApplication.callInitHook (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\core\nest-application-context.js:223:13) at NestApplication.init (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\core\nest-application.js:100:9) at NestApplication.listen (C:\study\00-codecamp-backend\연습장\memo01\node_modules\@nestjs\core\nest-application.js:169:33)
-
미해결따라하며 배우는 NestJS
port 5432 failed: recived invalid response to ssl negotiation
이런 오류메세지가 나오는데 방법좀 부탁드립니다. nestJS서버는 5432포트로 돌아가고 있습니다!!
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
에러 해결하고 데이터베이스 초기화하기 파트
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.코드팩토리 통합 링크https://links.codefactory.ai안녕하세요 혹시 원래 만든 postModel 인터페이스에서 export interface PostModel { id: number; author: string; title: string; content: string; likeCount: number; commentCount: number;}이렇게 author가 string으로 되어있어서 오류가 나오는데 이건 어떻게 처리하나요? The expected type comes from property 'author' which is declared here on type 'DeepPartial<PostModel>'터미널에서는 이렇게 오류가 나옵니다타입 관련 오류인데 이게 아래에선 postmodel을 받는데 author을 authorId가 들어간 객체로 받는데 위에선 선언을 string으로 해줬는데 이것도 잘 이해가 안 갑니다.. async createPost(authorId: number, title: string, content: string) { // 1) create -> 저장할 객체를 생성한다. // 2) save -> 객체를 저장한다. (create 메서드에서 생성한 객체로) const post = this.postsRepository.create({ author: { id: authorId, }, title, content, likeCount: 0, commentCount: 0, }); const newPost = await this.postsRepository.save(post); return newPost;}
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
관계형 연결되어있는 DB 모델 삭제 시 에러 처리
안녕하세요. 강의 잘 듣고 있습니다.image multer 적용 후, 몇가지 api를 테스트 하던중에 아래와 같은 에러가 발생하여, 해결하고자 시도를 해보았는데 잘 해결 되지 않아 질문 드립니다. 에러 메세지QueryFailedError: update or delete on table "posts_model" violates foreign key constraint "FK_40cd89c6655ec7b102842feacab" on table "image_model"에러 발생 상황- image가 post 모델에 관계형이 지어있는 상황에서, post를 지우려고 하면 (deletePost API 사용) 위와 같은 에러 메세지가 나오며 에러가 발생합니다.에러 해결을 위한 시도- onDelete : "CASCADE" 옵션을 posts model에 주고, db를 초기화 한후 다시 시도해보았지만 같은 상황이 발생하였습니다.해당 에러를 어떤식으로 해결해야할지 말씀 부탁드립니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
예외처리, 함수 Return type 관련하여 질문 드립니다!
안녕하세요!수업 수강 중 궁금한 부분이 생겨 질문 드립니다! 질문 1) Section 11-01 수업 중 users.service.ts 에서 create 함수를 만들 때 const user = await this.findOneByEmail({ email }); if (user) throw new ConflictException('이미 등록된 이메일입니다.');위와 같이 email을 검사하고 이미 이메일이 있으면 예외처리를 해주게 되는데Entity 구현 시 email에 { unique: true } 를 주어도 위 코드처럼 예외처리를 해주어야 하는건가요? 질문 2) Section 10의 products.service.ts 에서 create 함수를 만들 때 함수의 return type은Promise<Product> 로 구현을 했는데,const result2 = this.productsRepository.save({ ...product, productSalesLocation: result, productCategory: { id: productCategoryId, // 만약 name 까지 받고 싶으면? // => createProductInput에 name까지 포함해서 받아오기 }, productTags: tags, }); return result2;이런 식으로 result2 를 return 하게 되면 플레이그라운드에서 return 을 선택할 때 productCategory.name 까지 선택할 수 있게 되어 있더라구요.주석에 쓰여진 내용처럼 name 을 받고 싶으면 createProductInput 에 name을 포함하면 되지만, 지금 처럼 id만 save할 경우, 프론트 개발자 또는 이 API 사용자에게는 productCategory.name이 없다고 매 번 설명을 해야하는 번거로움이 있을 것 같은데 이런 경우 함수의 return type을 새로 정의하기도 하나요?ex) class ProductsServiceCreateReturn ...
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
이미지파일 선 업로드 방식에서 update 로직
강사님 안녕하세요. 파일 업로드 기능 중 선 업로드 방식에서 update로직을 구현하려고 합니다. 한 개의 포스트에 1,2,3 이미지를 인서트해당 포스트에 이미지를 2번 삭제하고 4번 추가 하여 업데이트 이럴 경우, 이미지 테이블을 모두 삭제한 후 1,3,4 이미지 파일명을 이미지 테이블에 넣어주면 될까요?1,3 이미지는 public/post 경로에 이미 있고 3이미지는 temp 경로에 있을텐데 public폴더와 temp 폴더를 모두 access 해봐서 temp에 있는 경우만 이미지 파일위치를 옮겨주면 될지 Update를 어떻게 구현하면 좋을지.,문의드립니다. 좋은강의 정말 감사합니다!
-
미해결탄탄한 백엔드 NestJS, 기초부터 심화까지
[건의사항] tsc 패키지가 더 이상 관리되지않아(deprecated) 디펜던시에서 삭제하는 것이 어떨까 싶습니다.
[건의사항] tsc 패키지가 더 이상 관리되지않아(deprecated) package.json의 디펜던시에서 삭제하는 것이 어떨까 싶습니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
yarn add @apollo-server 405 에러...
설치하려하는데 405 에러 나오네요....검색해서 나오는것도 몇가지 해보긴했는데...해결이 안되서 올려봅니다~## 에러메시지Error: https://registry.npmjs.org/@apollo-server: Request "https://registry.npmjs.org/@apollo-server" returned a 405
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
post 업데이트 코드 이렇게 작성해도 되나요?
async patchPost(id: number, title: string, content: string, author: string) { const post = await this.postsRepository.save({ id, title, content, author, }); if (!post) { throw new NotFoundException(); } return post; }
-
해결됨타입스크립트의 모든 것
ts-node extends시 에러가 발생합니다 ㅠㅠ
tsconfig.json에서"extends": "@tsconfig/node16/tsconfig.json", extends를 하고 다시 ts-node 명령어를 실행하면 아래와 같이 에러가 발생합니다.tsconfig.json을 주석처리하고 ts-node를 하면 잘 수행됩니다..! /usr/local/lib/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: error TS6053: File '@tsconfig/node16/tsconfig.json' not found. at createTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:859:12) at reportTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:863:19) at createFromPreloadedConfig (/usr/local/lib/node_modules/ts-node/src/index.ts:874:36) at phase4 (/usr/local/lib/node_modules/ts-node/src/bin.ts:543:44) at bootstrap (/usr/local/lib/node_modules/ts-node/src/bin.ts:95:10) at main (/usr/local/lib/node_modules/ts-node/src/bin.ts:55:10) at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/bin.ts:800:3) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) { diagnosticCodes: [ 6053 ] }현재 노드 버전 : v17.0.1노드를 완전 삭제 및 다시 설치해도 동일한 현상이 발생하고노드 버전을 올리고 내려도 동일한 현상이 발생하네요..혹시 해당 에러가 왜 발생할까요? ㅠㅠ검색을 해도 잘 나오지가 않네요 ㅠㅠ
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
Github
터미널에 'git push origin master'를 입력하고 엔터를 누르면fatal: 'origin' does not appear to be a git repositoryfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists. 이렇게 나와고 있어요. 어디서 실수했어요?
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
yarn start:dev 이후 에러
docker-compose.yaml 파일 작성하고postgres-data폴더도 생성하고app.module.ts도 똑같이 작성되어 있는 상태입니다도커가 실행되어있고, docker-compose up을 실행한 뒤에다른 터미널에서 yarn start:dev를 하면 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...error: "typeormstudy" �����ͺ��̽� ���� at Parser.parseErrorMessage 이런 에러 메세지가 출력되면서 정상적으로 실행되지 않습니다이전 강의에서 사용하던 프로젝트도 모두 종료가 되어있는 상태입니다제가 어딘가를 놓쳐서 나오는 에러일까요..?
-
해결됨타입스크립트의 모든 것
데코레이터-2 강의 질문이 있습니다.
데코레이터-2 강의에서 팩토리 안에 있는 데코레이터 함수를 실행하면 첫번째 인자인 target: Function쪽에는 강의와 다르게 빈값({})이 출력되는데요..! 혹시 이유를 아실까하여 여쭤봅니다..!tsconfig.json에서 말씀해주신 2개의 옵션 수정한 상태입니다.좋은 강의에 감사의 말씀 전달드립니다!!class HelloController { @Get("/api/v1/user") getRequest() {} } function Get(params: any): any { console.log("Get factory params : ", params); return ( target: any, propertyKey: string, descriptor: PropertyDescriptor) => { console.log("Get deco func : ", target); console.log("Get propertyKey : ", propertyKey); console.log("Get descriptor: ", descriptor); } } 출력값 Get factory params : /api/v1/user Get deco func : {} Get propertyKey : getRequest Get descriptor: { value: [Function: getRequest], writable: true, enumerable: false, configurable: true }
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
[질문] 토큰 만료에 대한 예외처리 질문
안녕하세요, 현재 강의 를 듣고 있는 수강생입니다.BearerTokenGuard를 작성하고, 토큰 유효기간이 지난 경우에 대해서도테스트 상황을 가정하여 전날 만들어둔 access token을 authorization header에 넣어테스트 해보았습니다. 그런데 verifyToken api에 try,catch문이 없어서 500 코드의 에러가 발생하더라구요.그래서 일단 401 error를 내는게 맞는것 같아서 아래와 같이 작성을 했는데, verify의 결과가 무조건 토큰이만료된 경우 1가지인지 확실치 않아, 잘 작성된 코드인지 모르겠어서 질문 드립니다. 어떻게 예외처리 코드를 작성하면 좋을까요? /* 해당 API는 토큰을 검증하는 API 입니다. */ verifyToken(token: string) { try { const result = this.jwtService.verify(token, { secret: JWT_SECRET, }); return result; } catch (error) { // to-do : 나중에 최적화 throw new UnauthorizedException('만료된 토큰입니다. 재발급해주세요'); } }
-
해결됨타입스크립트의 모든 것
enum 질문이 있습니다.
안녕하세요! 강의 잘 보구 있습니다.enum에는 값 외에 object나 함수를 지정할 수 없나요?java에서의 enum에서는 값 외에 행위나 인터페이스 등의 타입을 부여할 수 있어서 혹시 가능한지 여쭤봅니다 ㅎㅎ
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
many to many relations update를 할 경우 질문 드립니다.
안녕하세요. 강의 정말 잘 듣고 있습니다.먼저 좋은 강의 감사드립니다.강의를 듣고 복습을 하던 중에, 기존 tag가 relation된 post를 찾아서 새로운 tag를 추가하는 API는 어떤 식으로 짜야 하는지 궁금해서 질문 드립니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
AccessToken은 잘 만들어지는데 payload에 아무것도 안담겨요
로그인 시 받은 accesstoken을 밑에 /user/test의 헤더에 넣었습니다.처음에는 payload에 값이 담겼는데 갑자기 아무것도 안담기네요ㅜㅜ변경사항이 있었던 건 다 돌려봤는데도 도저히 뭐가 문제인지 모르겠어서 남깁니다.뭐가 문제인지도 모르겠어서 코드도 뭘 보여드려야 할 지 모르겠네요ㅜㅜ accesstoekn은 잘 만들어지는데.. 저 accesstoekn으로 UseGuards(AuthGuard('access')) 이 가드를 통과하는 거 아닌가요?validate()까지 간 거 보면 인가는 됐다고 생각했는데 왜 payload에 아무것도 안담기는지 모르겠네요ㅜㅜ
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
AlreadyHasActiveConnectionError 에러 발생
에러 해결하였습니다..app.module.ts > typeOrmModuleOptions에keepConnectionAlive: true 옵션이 빠져있어 발생한 에러였습니다. 검색해보니 '어플리케이션 종료 시 DB 연결 유지'에 대한 내용인데제가 다른 옵션과 착각하고 주석 처리했었습니다. 현재 옵션 활성화 하였고 e2e 테스트 정상적으로 진행되는거 확인했습니다.const typeOrmModuleOptions = { useFactory: async ( configService: ConfigService, ): Promise<TypeOrmModuleOptions> => ({ namingStrategy: new SnakeNamingStrategy(), // ... keepConnectionAlive: true, }), 검색해보니 beforeEach에 있는 app.init() 메소드에서 어플리케이션을 초기화하며 DB 연결도 초기화되는데,어플리케이션을 재초기화하는 것이지 종료한 적은 없었기에 여전히 'default'라는 이름으로 활성화된 DB 연결이 존재하였고,DB 연결 재초기화 중 'default라는 이름으로 새로운 DB 연결이 실패하였다' 에러가 발생한 것이며 keepConnectionAlive: true 옵션을 줌으로써DB 연결은 어플리케이션의 생명주기와는 별도로 존재하게 되고, 이미 활성화된 DB 연결이 존재하므로 새로운 DB 연결을 시도하지 않는다 라고 합니다..공부가 되었네요. app.e2e-spec.ts의 afterEach 메소드는 제거하였습니다. ============================================================= 안녕하세요 강사님강의따라 진행하다 에러가 발생하여 질문글 남깁니다. 에러 메세지는 아래와 같습니다.[Nest] 26544 - 2023. 11. 25. 오후 11:01:36 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... AlreadyHasActiveConnectionError: Cannot create a new connection named "default", because connection with such name already exist and it now has an active connection session. at AlreadyHasActiveConnectionError.TypeORMError [as constructor] (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\TypeORMError.ts:7:9) at new AlreadyHasActiveConnectionError (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\AlreadyHasActiveConnectionError.ts:8:9) at ConnectionManager.Object.<anonymous>.ConnectionManager.create (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\connection\ConnectionManager.ts:57:23) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\globals.ts:77:35 at step (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:124:57) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:113:16) at createConnection (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\typeorm\globals.js:55:20) [Nest] 26544 - 2023. 11. 25. 오후 11:01:39 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)... AlreadyHasActiveConnectionError: Cannot create a new connection named "default", because connection with such name already exist and it now has an active connection session. at AlreadyHasActiveConnectionError.TypeORMError [as constructor] (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\TypeORMError.ts:7:9) at new AlreadyHasActiveConnectionError (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\AlreadyHasActiveConnectionError.ts:8:9) at ConnectionManager.Object.<anonymous>.ConnectionManager.create (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\connection\ConnectionManager.ts:57:23) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\globals.ts:77:35 at step (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:124:57) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:113:16) at createConnection (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\typeorm\globals.js:55:20) FAIL test/app.e2e-spec.ts (10.952 s) AppController (e2e) √ / (GET) (845 ms) hello jest × two plus two is four (5014 ms) ● AppController (e2e) › hello jest › two plus two is four thrown: "Exceeded timeout of 5000 ms for a hook. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 7 | let app: INestApplication; 8 | > 9 | beforeEach(async () => { | ^ 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); at app.e2e-spec.ts:9:3 at Object.<anonymous> (app.e2e-spec.ts:6:1) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 passed, 2 total Snapshots: 0 total Time: 11.106 s Ran all test suites. Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot 읽어보니 이미 'default'라는 이름의 연결이 존재하고, 현재 활성화 중이므로 같은 이름의 연결을 또 생성할 수 없다는 것 같고,검색해보니 beforeEach 메소드 안에 Test.createTestingModule이 매 테스트마다 DB 연결을 시도하는 상황이라고 나왔습니다.. 하여 아래와 같이 afterEach 메소드를 사용하여 매 테스트마다 어플리케이션을 종료해주도록 코드를 수정하였습니다.describe('AppController (e2e)', () => { let app: INestApplication; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication(); await app.init(); }); // 테스트 2개 이상 사용할 경우 필요한 메소드 afterEach(async () => { await app.close(); }); it('/ (GET)', () => { return request(app.getHttpServer()) .get('/') .expect(200) .expect('typeorm in nest, just coding'); }); describe('hello jest', () => { it('two plus two is four', () => { expect(2 + 2).toBe(4); }); }); // 생략 수정 후 강의에서 진행했던 내용은 모두 완료가 되었는데..이제 궁금한 점은강사님과 코드 내용이 같고 도커나 DB 연결에 대하여 특별히 수정한 내용이 없는데왜 이런 상황이 발생하는 것인지. 버전이 달라 발생한 상황인 것인지.. 그리고 afterEach를 사용하였을때 당장 테스트 진행은 가능하지만 이대로 사용해도 괜찮을지 안좋은 것은 아닌지가 궁금합니다..