인프런 커뮤니티 질문&답변

특별한 까치님의 프로필 이미지
특별한 까치

작성한 질문수

따라하며 배우는 TDD 개발 [2023.11 업데이트]

updateProduct 통합 테스트 작성 (1)

Jest did not exit one second after the test run has completed. 이슈

작성

·

2.8K

0

안녕하세요!!

 

npm test를 하면 끝부분에 항상 다음과 같은 메세지가 나오는데요,

>>>>>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 this issue.

^C

<<<<<<<

위 문제를 해결해주기 위해 package.json을 다음과 같이 설정해주면,

>>>>>>>

"scripts": {
"test": "jest --detectOpenHandles"
},

<<<<<<<<

위에 나왔던 메세지 대신에 아래와같은 에러 메세지가 나옵니다.

>>>>>>>>>

 

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

 

  ●  TCPWRAP

 

       9 | const mongoose = require('mongoose');

      10 |

    > 11 | mongoose.connect(

         |          ^

      12 |   'mongodb://127.0.0.1:27017/tdd-test',

      13 |   {

      14 |     useNewUrlParser: true,

 

      at makeConnection (node_modules/mongodb/src/cmap/connect.ts:395:18)

      at connect (node_modules/mongodb/src/cmap/connect.ts:61:3)

      at checkServer (node_modules/mongodb/src/sdam/monitor.ts:300:10)

      at node_modules/mongodb/src/sdam/monitor.ts:341:5

      at executeAndReschedule (node_modules/mongodb/src/utils.ts:1026:5)

      at makeInterruptibleAsyncInterval (node_modules/mongodb/src/utils.ts:1033:5)

      at Monitor.connect (node_modules/mongodb/src/sdam/monitor.ts:147:54)

      at Server.connect (node_modules/mongodb/src/sdam/server.ts:236:22)

      at createAndConnectServer (node_modules/mongodb/src/sdam/topology.ts:907:10)

      at node_modules/mongodb/src/sdam/topology.ts:921:22

          at Array.reduce (<anonymous>)

      at connectServers (node_modules/mongodb/src/sdam/topology.ts:919:43)

      at Topology.connect (node_modules/mongodb/src/sdam/topology.ts:438:5)

      at createTopology (node_modules/mongodb/src/operations/connect.ts:97:12)

      at connect (node_modules/mongodb/src/operations/connect.ts:52:10)

      at node_modules/mongodb/src/mongo_client.ts:432:14

      at maybePromise (node_modules/mongodb/src/utils.ts:609:3)

      at MongoClient.connect (node_modules/mongodb/src/mongo_client.ts:431:24)

      at node_modules/mongoose/lib/connection.js:796:12

      at NativeConnection.Object.<anonymous>.Connection.openUri (node_modules/mongoose/lib/connection.js:781:19)

      at node_modules/mongoose/lib/index.js:340:10

      at node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5

      at promiseOrCallback (node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)

      at Mongoose.Object.<anonymous>.Mongoose._promiseOrCallback (node_modules/mongoose/lib/index.js:1140:10)

      at Mongoose.connect (node_modules/mongoose/lib/index.js:339:20)

      at Object.<anonymous> (server.js:11:10)

      at Object.<anonymous> (test/itegration/product.int.test.js:2:13)

 

<<<<<<<<<

 

이런 에러나 메세지가 나오지 않도록 조치할 수 있는 방법이 있을까요?

 

감사합니다.

 

 

 

 

답변 3

1

John Ahn님의 프로필 이미지
John Ahn
지식공유자

안녕하세요 쭁님 

항상 열공하시네요!! 

이 부분에 답변은 

https://www.inflearn.com/questions/437973 

여기 한번 참조해 주실 수 있을까요? 

감사합니다!

0

In this five-minute game, the slight variations in your shots will be blown up into enormous monsters. Come discover more buried treasures! we become what we behold is a fun and enlightening game with an endless news cycle.

0

답변 감사드립니다!!

특별한 까치님의 프로필 이미지
특별한 까치

작성한 질문수

질문하기