P
Prisma19h ago
Osamu

Mocking prisma client with javascript

How can I mock prisma client with javascript? The guides I found are heavily depended on typescript
Solution:
Hi @Osamu Can you take a look at this repo ? I created a mock example in Javascript using Prisma....
GitHub
GitHub - ludralph/mocking_playground
Contribute to ludralph/mocking_playground development by creating an account on GitHub.
Jump to solution
11 Replies
Solution
RaphaelEtim
RaphaelEtim19h ago
Hi @Osamu Can you take a look at this repo ? I created a mock example in Javascript using Prisma.
GitHub
GitHub - ludralph/mocking_playground
Contribute to ludralph/mocking_playground development by creating an account on GitHub.
RaphaelEtim
RaphaelEtim19h ago
It's based off of the guides but i used Javascript instead of Typescript.
Osamu
OsamuOP19h ago
That's actually pretty cool thanks man I hope this gets into the documentation soon
RaphaelEtim
RaphaelEtim19h ago
I'll add a similar example to the Prisma Example repository so it can be easy for our users to find.
GitHub
GitHub - prisma/prisma-examples: 🚀 Ready-to-run Prisma example proj...
🚀 Ready-to-run Prisma example projects. Contribute to prisma/prisma-examples development by creating an account on GitHub.
Osamu
OsamuOP18h ago
Pardon but it should work with es6 right? Or does it need more configuration?
Osamu
OsamuOP17h ago
I've tried to implement it I kept getting problem related to ES6 I couldn't mock the prisma client sadly
RaphaelEtim
RaphaelEtim17h ago
Can you please share the error you're facing?
Osamu
OsamuOP17h ago
/home/mohammad/Desktop/ALX/HealthVault/tests/patient.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import PatientController from "../controllers/PatientController"
^^^^^^

SyntaxError: Cannot use import statement outside a module

at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
/home/mohammad/Desktop/ALX/HealthVault/tests/patient.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import PatientController from "../controllers/PatientController"
^^^^^^

SyntaxError: Cannot use import statement outside a module

at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
I'm trying to use es6
RaphaelEtim
RaphaelEtim17h ago
You need to configure Jest to support ES6 module. You could check resources online on how to do that
Osamu
OsamuOP16h ago
Thank you
RaphaelEtim
RaphaelEtim15h ago
You're welcome
Want results from more Discord servers?
Add your server