Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
prisma-mock
Advanced tools
This is a mock of the Prisma API intended for unit testing. All the data is stored in memory.
The library jest-mock-extended
is used, which means that if functionality you need is not implemented yet, you can mock it yourself.
Simple example how to create a prisma mock instance:
import createPrismaMock from "prisma-mock"
let client
beforeEach(async () => {
client = await createPrismaMock()
}
An example how to mock a global prisma instance inside and schema a "db" directory (like blitzjs):
import createPrismaMock from "prisma-mock";
import { mockDeep, mockReset } from "jest-mock-extended";
jest.mock("db", () => ({
__esModule: true,
...jest.requireActual("db"),
default: mockDeep(),
}));
import db, { Prisma } from "db";
beforeEach(() => {
mockReset(db);
return createPrismaMock({}, Prisma.dmmf.datamodel, db);
});
createPrismaMock(
data: PrismaMockData<P> = {},
datamodel?: Prisma.DMMF.Datamodel,
client = mockDeep<P>()
): Promise<P>
Object with an array per table of default data (using create
is preferred). Example:
createPrismaMock({
users: [
{
id: 1,
name: "John Doe",
accountId: 1,
},
],
account: [
{
id: 1,
name: "Company",
},
],
});
The datamodel of the prisma client, value of Prisma.dmmf.datamodel
.
jest-mock-extended
instance used. If not provided, a new instance is created.
Alot of the functionality is implemented, but parts are missing. Here is a list of the (missing) features:
TODO (set, push)
TODO (has, hasEvery, hasSome, isEmpty, equals)
TODO (path, string_contains, string_starts_with, string_ends_with, array_contains, array_starts_with, array_ends_with)
FAQs
Mock prisma for unit testing database
The npm package prisma-mock receives a total of 3,598 weekly downloads. As such, prisma-mock popularity was classified as popular.
We found that prisma-mock demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.