sabinadams / express_sample_app Goto Github PK
View Code? Open in Web Editor NEWSample Express Application used to teach Unit/Integration/E2E Tests
Sample Express Application used to teach Unit/Integration/E2E Tests
import { PrismaClient } from '@prisma/client'
import { beforeEach } from 'vitest'
import { mockDeep, mockReset } from 'vitest-mock-extended'
beforeEach(() => {
mockReset(prisma)
})
const prisma = mockDeep<PrismaClient>()
export default prisma
describe('createUser', async () => {
it('should create and return the user', async () => {
prismaMock.user.create.mockResolvedValueOnce({
id: 1,
name: 'testname',
email: 'testemail',
password: 'testpassword',
} as User);
const newUser = await UserService.createUser({
method: 'local',
name: 'testname',
email: 'testemail',
password: 'testpassword'
})
expect(newUser).toHaveProperty('id')
expect(newUser).toHaveProperty('username')
expect(newUser).toStrictEqual({
id: 1,
name: 'testname',
email: 'testemail',
password: 'testpassword'
})
})
})
Error:
(method) Prisma.UserDelegate<GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation, ExtArgs extends Args_3 = DefaultArgs>.create(args: Prisma.SelectSubset<T, Prisma.UserCreateArgs>): Prisma.Prisma__UserClient<GetFindResult<UserPayload, T>, never, DefaultArgs> (+1 overload)
Create a User.
@param args โ Arguments to create a User.
// Create one User
const User = await prisma.user.create({
data: {
// ... data to create a User
}
})
Type of property 'AND' circularly references itself in mapped type '{ [K in keyof { AND?: Enumerable; OR?: Enumerable; ... 18 more ...; updatedAt?: string | ... 1 more ... | DateTimeWithAggregatesFilter; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends FieldPaths<....'.ts(2615)
Type of property 'NOT' circularly references itself in mapped type '{ [K in keyof { AND?: Enumerable; OR?: Enumerable; ... 18 more ...; updatedAt?: string | ... 1 more ... | DateTimeWithAggregatesFilter; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends FieldPaths<....'.ts(2615)
Type of property 'OR' circularly references itself in mapped type '{ [K in keyof { AND?: Enumerable; OR?: Enumerable; ... 18 more ...; updatedAt?: string | ... 1 more ... | DateTimeWithAggregatesFilter; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends FieldPaths<....'.ts(2615)
Dependencies:
"prisma": "4.16.0",
"vitest": "^0.34.6",
"vitest-mock-extended": "^1.3.1"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.