sodatea / vite-jest

First-class Vite integration for Jest
MIT License
401 stars 51 forks source link

Jest did not exit one second after the test run has completed #33

Open BenjaBobs opened 2 years ago

BenjaBobs commented 2 years ago

Hi!

In my current setup I'm using the following versions

"scripts": {
    "test": "vite-jest",
},
"devDependencies": {
    "jest": "^27.4.3",
    "jest-environment-jsdom": "^27.4.3",
    "vite": "^2.7.1",
    "vite-jest": "^0.1.4"
}

My test runs fine and everything passes, but after that, I get the following message:

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.

And the process just hangs. This is fine for local development (I can just CTRL+C), but it freezes my CI pipeline.

BenjaBobs commented 2 years ago

I made it work by adding the option --forceExit

-   "test": "vite-jest",
+   "test": "vite-jest --forceExit",

You can close this issue if you want. 🙂

aapzu commented 2 years ago

I'm having the same issue. '--forceExit' works, but does not feel like a very good long-term solution

rszemplinski commented 2 years ago

Agreed, according to the --detectOpenHandles it's saying that it's related to esbuild. Don't know why or how to fix it but thought I'd post it here.

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

  ●  MESSAGEPORT

      at startWorkerThreadService (../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1978:48)
      at Object.buildSync (../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1757:29)

  ●  WORKER

      at startWorkerThreadService (../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1979:16)
      at Object.buildSync (../../node_modules/.pnpm/esbuild@0.13.15/node_modules/esbuild/lib/main.js:1757:29)