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

mocha + ts-node hangs with node 16 #1462

Closed
cvlmtg opened this issue Sep 16, 2021 · 3 comments
Closed

mocha + ts-node hangs with node 16 #1462

cvlmtg opened this issue Sep 16, 2021 · 3 comments

Comments

@cvlmtg
Copy link

cvlmtg commented Sep 16, 2021

I've setup mocha to run some TS tests with ts-node and under node 14 everything runs smoothly, but under node 16 it executes the tests and then hangs forever, so I have to press ctrl-c to get back to the shell prompt.

Search Terms

  • node 16
  • node16
  • mocha

Expected Behavior

mocha completes its operation under node 16 as it does with node 14

Actual Behavior

when run under node 16 all tests are executed but then mocha hangs forever

Schermata 2021-09-16 alle 15 23 49

Schermata 2021-09-16 alle 15 24 11

Steps to reproduce the problem

just run yarn test

Minimal reproduction

TypeStrong/ts-node-repros#18

Specifications

ts-node v10.2.1
node v16.9.1
compiler v4.4.3

{
  "include": [ "src", "types" ],
  "compilerOptions": {
    "module": "esnext",
    "lib": [ "dom", "esnext" ],
    "importHelpers": true,
    "declaration": true,
    "sourceMap": true,
    "rootDir": "./src",
    "strict": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "moduleResolution": "node",
    "jsx": "react",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true
  },
  "ts-node": {
    "compilerOptions": {
      "module": "commonjs"
    },
    "transpileOnly": true
  }
}
  • Operating system and version: macOS 11.5.2, iTerm2 3.4.8
@cspotcode
Copy link
Collaborator

@cvlmtg first order of business will be to determine if this is a mocha issue or not. Have you done any investigation to figure out if mocha bas a bug related to require hooks or other things that ts-node needs to do?

@cspotcode
Copy link
Collaborator

I see your reproduction contains some dependencies that are not mentioned in your description. Have you tried removing them? The reproduction will need to be minimal, which means including only the absolute bare minimum of dependencies.

@cvlmtg
Copy link
Author

cvlmtg commented Sep 16, 2021

@cspotcode I tried to search anything related to mocha and ts-node and node 16 and found nothing.

anyway, I tried to make the repro as minimal as possible and everything works fine. If I reintroduce react-testing-library (and jsdom) the problem appears again. so (if I did everything correctly) it seems it's not a problem of ts-node but of one of those libraries. thanks for the help!

(I pushed my tests anyway, just in case they might be useful to someone)

@cvlmtg cvlmtg closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants