Has anyone gotten the unit testing guide working w...
# orm-help
s
Has anyone gotten the unit testing guide working with the latest version of Jest and jest-mock-extended? https://www.prisma.io/docs/guides/testing/unit-testing
1
n
Hey 👋 What error are you getting in the latest version of jest and jest-mock-extended?
s
Hey @Nurul, I added the details to the discussion here https://github.com/prisma/prisma/discussions/7084#discussioncomment-3336345 - Thanks!
👀 1
Hey @Nurul, any idea what might be missing or, what I might be doing wrong? Thanks!
I decided to try and do the unit testing tutorial in a separate isolated repo to see if I can get it to work that way. I very quickly ran into a problem however. When running
npm install --save-dev jest typescript ts-jest @types/jest
it will install the latest versions of these dependencies. If you now run
npm install jest-mock-extended@2.0.4 --save-dev
as stated in the tutorial, I get:
Copy code
❯ npm install jest-mock-extended@2.0.4 --save-dev
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: prisma-unit-testing@1.0.0
npm ERR! Found: jest@28.1.3
npm ERR! node_modules/jest
npm ERR!   dev jest@"^28.1.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0" from jest-mock-extended@2.0.4
npm ERR! node_modules/jest-mock-extended
npm ERR!   dev jest-mock-extended@"2.0.4" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/schalkneethling/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/schalkneethling/.npm/_logs/2022-08-13T18_58_03_126Z-debug-0.log
1
I also notice in the quick start guide at step 4 https://www.prisma.io/docs/getting-started/quickstart#4-explore-how-to-send-queries-to-your-database-with-prisma-client, it starts to use the
PrismaClient
but there has been no instructions to install the client. For example here it does clearly explain to do so: https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/mongodb/install-prisma-client-typescript-mongodb
I got this all working but had to do quite a bit of cross-reference 🙂 Will see if I can figure what is different in my project that stops it from running there.
@Nurul ^^
n
Thanks for writing the descriptive comment! It would be immensely helpful. 🙌
s
You are welcome 🙌