Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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 from "db"
beforeEach(() => {
mockReset(db)
return createPrismaMock({}, "db/schema.prisma", db)
})
createPrismaMock(
data: PrismaMockData<P> = {},
pathToSchema?: string,
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",
}
]
})
Path to the schema file. If not provided, the schema is prisma/schema.prisma
.
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,673 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.