Testing documentation tutorial results in errors
See original GitHub issueHey all!
First of all, I’d like to say that I am very enthusiastic about the future of nexus and prisma. It’s been great fun learning these tools the past few weeks! I’ve started an attempt to write a test suite for an API I’m working on, following the tutorial on the nexus documentation site. https://nexusjs.org/docs/getting-started/tutorial/chapter-testing-your-api
However, two things arose as I was following this step:
- The pm add command in the article
npm add --save-dev jest @types/jest ts-jest graphql-request
does not mention theget-port
npm package which is later used intests/__helpers.ts
- After running my tests, jest gives the error message
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.
and doesn’t terminate. Running with the--detectOpenHandles
flag hides the warning message but jest still doesn’t terminate and shows no extra output.
Maybe a pointer towards the solution of the second issue: when I run a development server of the api on port 4000 and I have a test suite with only one test which I also run on port 4000, the warning is not displayed and jest exits as normal.
The project I’m working on is based on the code in this project from the prisma-examples repo: https://github.com/prisma/prisma-examples/tree/latest/typescript/subscriptions-pubsub.
I am not experienced with jest (or rather, software testing as a whole) and I would love some help. Is anyone else experiencing the same issue?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Pass the
--forceExit
flag to jest. I fixed a bunch of things in the tutorial tonight and updated https://github.com/graphql-nexus/tutorial. Hope it helps!@jasonkuhrt After further debugging I found the issue to be that the Prisma Client connection was never disconnected and hence prevented Jest from exiting. Although using
--forceExit
worked, it wasn’t a fix and it was just a workaround. I submitted a proper fix in graphql-nexus/tutorial#13. Let me know if you’re okay with it and I could probably update the docs in this repo accordingly 🙂