prismock
prismock copied to clipboard
TypeError: Cannot read properties of undefined (reading 'dmmf')
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.