Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix promise left hanging after unit tests finish #306

Merged
merged 10 commits into from Jul 4, 2023

Conversation

pedroferreira1
Copy link
Member

@pedroferreira1 pedroferreira1 commented Jun 16, 2023

Context

Issue: #292

The following log was found during unit tests

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

  ●  TCPSERVERWRAP

... 

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:59:33)
      at new Test (node_modules/supertest/lib/test.js:36:12)
      at Object.obj.(anonymous function) [as get] (node_modules/supertest/index.js:25:14)

Checking this issue one of the possibilities was that the supertest server was not being closed after the test.

I used the solution proposed here

Acceptance Criteria

  • Close open promises after unit test end
  • I decided to keep forceExit parameter for a while to understand if there could be other hanging places.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@pedroferreira1 pedroferreira1 marked this pull request as ready for review June 16, 2023 21:44
@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #306 (42894f1) into dev (4a8f508) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #306   +/-   ##
=======================================
  Coverage   86.98%   86.98%           
=======================================
  Files          35       35           
  Lines        1352     1352           
  Branches      269      269           
=======================================
  Hits         1176     1176           
  Misses        155      155           
  Partials       21       21           

@pedroferreira1 pedroferreira1 self-assigned this Jun 19, 2023
@pedroferreira1 pedroferreira1 changed the title tests: use detect open handles for the unit tests tests: fix promise left hanging after unit tests finish Jun 19, 2023
__tests__/test-utils.js Outdated Show resolved Hide resolved
__tests__/test-utils.js Show resolved Hide resolved
@pedroferreira1 pedroferreira1 merged commit 407f891 into dev Jul 4, 2023
9 checks passed
@pedroferreira1 pedroferreira1 deleted the tests/unit-tests-hanging branch July 4, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants