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] Jest may incorrectly detect open handles when running the tests #32

Open
JanEbbing opened this issue Jul 20, 2023 · 0 comments
Open
Assignees

Comments

@JanEbbing
Copy link
Member

Describe the bug
See fix in jest: jestjs/jest#13414
Unfortunately, this version of Jest (29.2+) requires Node 14.

To Reproduce
In the console, running tests may give a warning similar to the following

$ node_modules/.bin/jest --detectOpenHandles --no-cache tests/
 PASS  tests/general.test.ts
 PASS  tests/glossary.test.ts (24.288 s)
 PASS  tests/translateDocument.test.ts (31.975 s)
 PASS  tests/translateText.test.ts (6.858 s)

Test Suites: 4 passed, 4 total
Tests:       11 skipped, 50 passed, 61 total
Snapshots:   0 total
Time:        66.442 s
Ran all test suites matching /tests\//i.

Jest has detected the following 2 open handles potentially keeping Jest from exiting:

  ●  TLSWRAP

      220 |     ): Promise<{ statusCode: number; content: TContent }> {
      221 |         try {
    > 222 |             const response = await axios.request(axiosRequestConfig);
          |                                          ^
      223 |
      224 |             if (axiosRequestConfig.responseType === 'text') {
      225 |                 // Workaround for axios-bug: https://github.com/axios/axios/issues/907

      at node_modules/nock/lib/intercept.js:427:16
      at Object.module.request (node_modules/nock/lib/common.js:96:14)
      at RedirectableRequest.Object.<anonymous>.RedirectableRequest._performRequest (node_modules/follow-redirects/index.js:284:24)
      at new RedirectableRequest (node_modules/follow-redirects/index.js:66:8)
      at Object.request (node_modules/follow-redirects/index.js:523:14)
      at dispatchHttpRequest (node_modules/axios/lib/adapters/http.js:436:21)
      at node_modules/axios/lib/adapters/http.js:143:5
      at wrapAsync (node_modules/axios/lib/adapters/http.js:123:10)
      at http (node_modules/axios/lib/adapters/http.js:149:10)
      at Axios.dispatchRequest (node_modules/axios/lib/core/dispatchRequest.js:51:10)
      at Axios.request (node_modules/axios/lib/core/Axios.js:148:33)
      at Function.wrap [as request] (node_modules/axios/lib/helpers/bind.js:5:15)
      at Function.sendAxiosRequest (src/client.ts:222:42)
      at HttpClient.sendRequestWithBackoff (src/client.ts:176:45)
      at Translator.translateText (src/index.ts:571:63)
      at Object.<anonymous> (tests/translateText.test.ts:19:41)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (node_modules/@jest/core/build/runJest.js:404:19)
      at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
      at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)


  ●  TLSWRAP

      220 |     ): Promise<{ statusCode: number; content: TContent }> {
      221 |         try {
    > 222 |             const response = await axios.request(axiosRequestConfig);
          |                                          ^
      223 |
      224 |             if (axiosRequestConfig.responseType === 'text') {
      225 |                 // Workaround for axios-bug: https://github.com/axios/axios/issues/907

      at node_modules/nock/lib/intercept.js:427:16
      at Object.module.request (node_modules/nock/lib/common.js:96:14)
      at RedirectableRequest.Object.<anonymous>.RedirectableRequest._performRequest (node_modules/follow-redirects/index.js:284:24)
      at new RedirectableRequest (node_modules/follow-redirects/index.js:66:8)
      at Object.request (node_modules/follow-redirects/index.js:523:14)
      at dispatchHttpRequest (node_modules/axios/lib/adapters/http.js:436:21)
      at node_modules/axios/lib/adapters/http.js:143:5
      at wrapAsync (node_modules/axios/lib/adapters/http.js:123:10)
      at http (node_modules/axios/lib/adapters/http.js:149:10)
      at Axios.dispatchRequest (node_modules/axios/lib/core/dispatchRequest.js:51:10)
      at Axios.request (node_modules/axios/lib/core/Axios.js:148:33)
      at Function.wrap [as request] (node_modules/axios/lib/helpers/bind.js:5:15)
      at Function.sendAxiosRequest (src/client.ts:222:42)
      at HttpClient.sendRequestWithBackoff (src/client.ts:176:45)
      at Translator.translateText (src/index.ts:571:63)
      at Object.<anonymous> (tests/translateText.test.ts:221:41)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (node_modules/@jest/core/build/runJest.js:404:19)
      at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
      at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)

Expected behavior
Tests should run without throwing warnings.

@JanEbbing JanEbbing self-assigned this Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant