You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i have an issue trying to implement this package. It seems like im missing some configuration, and i cannot seem to be able to make it work.
I am getting an error TypeError: Cannot read properties of undefined (reading 'dmmf')
I have seen some threads talking about this issue but unfortunately all of them had been closed without much explaination of how this was fixed.
I am using Typescript
I have created a folder called __mocks__ with a subfolder @prisma and a file client.ts
with content of
import { PrismockClient } from 'prismock';
export * from '@prisma/client';
export { PrismockClient as PrismaClient };
my test looks like this
let repository: RepositoryImpl;
let database: SinonStubbedInstance<AppDatabase>;
beforeEach(() => {
cleanUpMetadata();
database = createStubInstance(PgDatabase);
repository = new RepositoryImpl(database);
});
afterEach(() => {
jest.restoreAllMocks();
});
describe("#getList", () => {
it("#getList returns a list", async () => {
// arrange
const prismock = new PrismockClient()
database.connect.resolves(prismock as PrismaClient);
// act
const result = await repository.getList(true);
// assert
expect(result).toEqual([]);
});
});
My prisma versions are "prisma": "^5.19.0" "@prisma/client": "^5.18.0" "prismock": "^1.33.3"
And my node version is 20.0.0
and after trying to run it, i am getting the error mentioned above. I would greatly appreciate help as i believe some kind of prisma mocking is essential for my project.
The text was updated successfully, but these errors were encountered:
Hello @Fasuh , I haven’t been able to reproduce with your exact use case, but I believe you should’nt mock Prisma through the mocks, if you are instantiating Prismock yourself.
If you can’t get it to work, is there any chance you can provide a public reproduction repo?
Hey @morintd , thanks for Prismock, I'm very keen to try and start using it on a project I'm contributing to called postiz.
I'm literally writing the very first unit tests for this project, and I'll admit that I'm really not that familiar with the javascript ecosystem, jest, etc, so I may not be doing something correct here, however I have a reproducer on a public branch; gitroomhq/postiz-app#331
You'll see in that PR that I'm using the mocks directory approach.
Hello, i have an issue trying to implement this package. It seems like im missing some configuration, and i cannot seem to be able to make it work.
I am getting an error
TypeError: Cannot read properties of undefined (reading 'dmmf')
I have seen some threads talking about this issue but unfortunately all of them had been closed without much explaination of how this was fixed.
I am using Typescript
I have created a folder called
__mocks__
with a subfolder@prisma
and a fileclient.ts
with content of
my test looks like this
My prisma versions are
"prisma": "^5.19.0"
"@prisma/client": "^5.18.0"
"prismock": "^1.33.3"
And my node version is 20.0.0
and after trying to run it, i am getting the error mentioned above. I would greatly appreciate help as i believe some kind of prisma mocking is essential for my project.
The text was updated successfully, but these errors were encountered: